@tatamicks/core 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";require('./index.css');var fr=Object.defineProperty;var pr=(e,t,n)=>t in e?fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var pt=(e,t,n)=>pr(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react");var qe={exports:{}},Ge={};/**
1
+ "use strict";require('./index.css');var pr=Object.defineProperty;var xr=(e,t,n)=>t in e?pr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var pt=(e,t,n)=>xr(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react");var qe={exports:{}},Ge={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var un;function xr(){if(un)return Ge;un=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,o,l){var i=null;if(l!==void 0&&(i=""+l),o.key!==void 0&&(i=""+o.key),"key"in o){l={};for(var a in o)a!=="key"&&(l[a]=o[a])}else l=o;return o=l.ref,{$$typeof:e,type:s,key:i,ref:o!==void 0?o:null,props:l}}return Ge.Fragment=t,Ge.jsx=n,Ge.jsxs=n,Ge}var Be={};/**
9
+ */var un;function br(){if(un)return Ge;un=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,o,l){var i=null;if(l!==void 0&&(i=""+l),o.key!==void 0&&(i=""+o.key),"key"in o){l={};for(var a in o)a!=="key"&&(l[a]=o[a])}else l=o;return o=l.ref,{$$typeof:e,type:s,key:i,ref:o!==void 0?o:null,props:l}}return Ge.Fragment=t,Ge.jsx=n,Ge.jsxs=n,Ge}var Be={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,12 +14,12 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var dn;function br(){return dn||(dn=1,process.env.NODE_ENV!=="production"&&(function(){function e(g){if(g==null)return null;if(typeof g=="function")return g.$$typeof===O?null:g.displayName||g.name||null;if(typeof g=="string")return g;switch(g){case h:return"Fragment";case m:return"Profiler";case p:return"StrictMode";case A:return"Suspense";case $:return"SuspenseList";case R:return"Activity"}if(typeof g=="object")switch(typeof g.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),g.$$typeof){case y:return"Portal";case _:return g.displayName||"Context";case w:return(g._context.displayName||"Context")+".Consumer";case D:var T=g.render;return g=g.displayName,g||(g=T.displayName||T.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case j:return T=g.displayName||null,T!==null?T:e(g.type)||"Memo";case M:T=g._payload,g=g._init;try{return e(g(T))}catch{}}return null}function t(g){return""+g}function n(g){try{t(g);var T=!1}catch{T=!0}if(T){T=console;var S=T.error,z=typeof Symbol=="function"&&Symbol.toStringTag&&g[Symbol.toStringTag]||g.constructor.name||"Object";return S.call(T,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",z),t(g)}}function s(g){if(g===h)return"<>";if(typeof g=="object"&&g!==null&&g.$$typeof===M)return"<...>";try{var T=e(g);return T?"<"+T+">":"<...>"}catch{return"<...>"}}function o(){var g=C.A;return g===null?null:g.getOwner()}function l(){return Error("react-stack-top-frame")}function i(g){if(L.call(g,"key")){var T=Object.getOwnPropertyDescriptor(g,"key").get;if(T&&T.isReactWarning)return!1}return g.key!==void 0}function a(g,T){function S(){k||(k=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",T))}S.isReactWarning=!0,Object.defineProperty(g,"key",{get:S,configurable:!0})}function c(){var g=e(this.type);return P[g]||(P[g]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),g=this.props.ref,g!==void 0?g:null}function d(g,T,S,z,me,Oe){var q=S.ref;return g={$$typeof:E,type:g,key:T,props:S,_owner:z},(q!==void 0?q:null)!==null?Object.defineProperty(g,"ref",{enumerable:!1,get:c}):Object.defineProperty(g,"ref",{enumerable:!1,value:null}),g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(g,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(g,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:me}),Object.defineProperty(g,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Oe}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g}function f(g,T,S,z,me,Oe){var q=T.children;if(q!==void 0)if(z)if(N(q)){for(z=0;z<q.length;z++)x(q[z]);Object.freeze&&Object.freeze(q)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else x(q);if(L.call(T,"key")){q=e(g);var ue=Object.keys(T).filter(function(Xe){return Xe!=="key"});z=0<ue.length?"{key: someKey, "+ue.join(": ..., ")+": ...}":"{key: someKey}",X[q+z]||(ue=0<ue.length?"{"+ue.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var dn;function vr(){return dn||(dn=1,process.env.NODE_ENV!=="production"&&(function(){function e(g){if(g==null)return null;if(typeof g=="function")return g.$$typeof===O?null:g.displayName||g.name||null;if(typeof g=="string")return g;switch(g){case h:return"Fragment";case m:return"Profiler";case p:return"StrictMode";case S:return"Suspense";case $:return"SuspenseList";case C:return"Activity"}if(typeof g=="object")switch(typeof g.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),g.$$typeof){case y:return"Portal";case _:return g.displayName||"Context";case w:return(g._context.displayName||"Context")+".Consumer";case D:var T=g.render;return g=g.displayName,g||(g=T.displayName||T.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case j:return T=g.displayName||null,T!==null?T:e(g.type)||"Memo";case M:T=g._payload,g=g._init;try{return e(g(T))}catch{}}return null}function t(g){return""+g}function n(g){try{t(g);var T=!1}catch{T=!0}if(T){T=console;var A=T.error,z=typeof Symbol=="function"&&Symbol.toStringTag&&g[Symbol.toStringTag]||g.constructor.name||"Object";return A.call(T,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",z),t(g)}}function s(g){if(g===h)return"<>";if(typeof g=="object"&&g!==null&&g.$$typeof===M)return"<...>";try{var T=e(g);return T?"<"+T+">":"<...>"}catch{return"<...>"}}function o(){var g=R.A;return g===null?null:g.getOwner()}function l(){return Error("react-stack-top-frame")}function i(g){if(L.call(g,"key")){var T=Object.getOwnPropertyDescriptor(g,"key").get;if(T&&T.isReactWarning)return!1}return g.key!==void 0}function a(g,T){function A(){k||(k=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",T))}A.isReactWarning=!0,Object.defineProperty(g,"key",{get:A,configurable:!0})}function c(){var g=e(this.type);return P[g]||(P[g]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),g=this.props.ref,g!==void 0?g:null}function d(g,T,A,z,me,Oe){var q=A.ref;return g={$$typeof:E,type:g,key:T,props:A,_owner:z},(q!==void 0?q:null)!==null?Object.defineProperty(g,"ref",{enumerable:!1,get:c}):Object.defineProperty(g,"ref",{enumerable:!1,value:null}),g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(g,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(g,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:me}),Object.defineProperty(g,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Oe}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g}function f(g,T,A,z,me,Oe){var q=T.children;if(q!==void 0)if(z)if(N(q)){for(z=0;z<q.length;z++)x(q[z]);Object.freeze&&Object.freeze(q)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else x(q);if(L.call(T,"key")){q=e(g);var ue=Object.keys(T).filter(function(Xe){return Xe!=="key"});z=0<ue.length?"{key: someKey, "+ue.join(": ..., ")+": ...}":"{key: someKey}",X[q+z]||(ue=0<ue.length?"{"+ue.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,z,q,ue,q),X[q+z]=!0)}if(q=null,S!==void 0&&(n(S),q=""+S),i(T)&&(n(T.key),q=""+T.key),"key"in T){S={};for(var ve in T)ve!=="key"&&(S[ve]=T[ve])}else S=T;return q&&a(S,typeof g=="function"?g.displayName||g.name||"Unknown":g),d(g,q,S,o(),me,Oe)}function x(g){b(g)?g._store&&(g._store.validated=1):typeof g=="object"&&g!==null&&g.$$typeof===M&&(g._payload.status==="fulfilled"?b(g._payload.value)&&g._payload.value._store&&(g._payload.value._store.validated=1):g._store&&(g._store.validated=1))}function b(g){return typeof g=="object"&&g!==null&&g.$$typeof===E}var v=u,E=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),_=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),R=Symbol.for("react.activity"),O=Symbol.for("react.client.reference"),C=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,N=Array.isArray,I=console.createTask?console.createTask:function(){return null};v={react_stack_bottom_frame:function(g){return g()}};var k,P={},F=v.react_stack_bottom_frame.bind(v,l)(),K=I(s(l)),X={};Be.Fragment=h,Be.jsx=function(g,T,S){var z=1e4>C.recentlyCreatedOwnerStacks++;return f(g,T,S,!1,z?Error("react-stack-top-frame"):F,z?I(s(g)):K)},Be.jsxs=function(g,T,S){var z=1e4>C.recentlyCreatedOwnerStacks++;return f(g,T,S,!0,z?Error("react-stack-top-frame"):F,z?I(s(g)):K)}})()),Be}var hn;function vr(){return hn||(hn=1,process.env.NODE_ENV==="production"?qe.exports=xr():qe.exports=br()),qe.exports}var r=vr(),Ce=(e=>(e.left="flex-start",e.center="center",e.right="flex-end",e))(Ce||{}),Re=(e=>(e.top="flex-start",e.center="center",e.bottom="flex-end",e))(Re||{});const gr="_container_1mr3i_5",wr="_select_1mr3i_11",_r="_placeholderOverlay_1mr3i_44",xt={container:gr,select:wr,placeholderOverlay:_r},we=e=>{const{value:t,onChange:n,readOnly:s=!1,config:o}=e,l=e.options??(o==null?void 0:o.options)??[],i=e.placeholder??(o==null?void 0:o.placeholder)??"選択してください",a=e.width??(o==null?void 0:o.width),c=e.height??(o==null?void 0:o.height),d=u.useCallback(E=>{const y=E.target.value;if(y==="")n(void 0);else{const h=l.find(p=>String(p.value)===y);n(h?h.value:y)}},[n,l]),f=t??"",x=t!==void 0&&t!=="",b={};a!==void 0?b.width=`${a}px`:b.width="100%";const v={width:"100%",height:c?`${c}px`:void 0};return r.jsxs("div",{className:xt.container,style:b,children:[!x&&r.jsx("input",{className:xt.placeholderOverlay,style:v,readOnly:!0,placeholder:i}),r.jsx("select",{className:xt.select,style:v,value:f,onChange:d,disabled:s,children:l.map(E=>r.jsx("option",{value:String(E.value),children:E.label},String(E.value)))})]})};we.displayName="Select";const xn={justifyContent:{defaultValue:Ce.left,label:"水平方向の配置",group:"配置",description:"ブロック内のコンテンツの水平方向の配置を設定します。",Component:we,config:{options:[{label:"左揃え",value:Ce.left},{label:"中央揃え",value:Ce.center},{label:"右揃え",value:Ce.right}]}},alignItems:{defaultValue:Re.center,label:"垂直方向の配置",group:"配置",description:"ブロック内のコンテンツの垂直方向の配置を設定します。",Component:we,config:{options:[{label:"上揃え",value:Re.top},{label:"中央揃え",value:Re.center},{label:"下揃え",value:Re.bottom}]}}},yr="_container_1tnp6_5",Er="_input_1tnp6_13",jr="_label_1tnp6_29",bt={container:yr,input:Er,label:jr},xe=({value:e,onChange:t,readOnly:n=!1,label:s,config:o})=>{const l=s??(o==null?void 0:o.label),i=u.useCallback(a=>{t(a.target.checked)},[t]);return r.jsxs("label",{className:bt.container,children:[r.jsx("input",{type:"checkbox",className:bt.input,checked:!!e,onChange:i,disabled:n}),l&&r.jsx("span",{className:bt.label,children:l})]})};xe.displayName="Checkbox";const Nr="_container_qbvob_5",Ir="_colorButton_qbvob_13",Dr="_textInputWrapper_qbvob_40",$r="_textInputPrefix_qbvob_62",Tr="_textInput_qbvob_40",Cr="_popover_qbvob_125",Rr="_palette_qbvob_141",Mr="_paletteButton_qbvob_148",kr="_selected_qbvob_171",Pr="_transparentPaletteButton_qbvob_177",Sr="_rgbaInputs_qbvob_183",Ar="_rgbaInputGroup_qbvob_190",Lr="_rgbaLabel_qbvob_205",te={container:Nr,colorButton:Ir,textInputWrapper:Dr,textInputPrefix:$r,textInput:Tr,popover:Cr,palette:Rr,paletteButton:Mr,selected:kr,transparentPaletteButton:Pr,rgbaInputs:Sr,rgbaInputGroup:Ar,rgbaLabel:Lr};function yt(e){if(!e)return null;const t=e.match(/^#([0-9a-f]{6}|[0-9a-f]{8})$/i);if(t&&typeof t[1]=="string"){const s=t[1],o=Number.parseInt(s.slice(0,2),16),l=Number.parseInt(s.slice(2,4),16),i=Number.parseInt(s.slice(4,6),16),a=s.length===8?Number.parseInt(s.slice(6,8),16)/255:1;return{r:o,g:l,b:i,a}}const n=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){const s=Number.parseInt(n[1]??"",10),o=Number.parseInt(n[2]??"",10),l=Number.parseInt(n[3]??"",10),i=n[4]?Number.parseFloat(n[4]):1;return{r:s,g:o,b:l,a:i}}return null}function bn(e){const{r:t,g:n,b:s,a:o}=e;if(o===0)return;const l=t.toString(16).padStart(2,"0"),i=n.toString(16).padStart(2,"0"),a=s.toString(16).padStart(2,"0");if(o<1){const c=Math.round(o*255).toString(16).padStart(2,"0");return`#${l}${i}${a}${c}`}return`#${l}${i}${a}`}function Or(e){const{r:t,g:n,b:s,a:o}=e;if(o!==0)return`rgba(${t}, ${n}, ${s}, ${o})`}function Gr(e){return/^#([0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)}const vn=[{label:"無色",value:void 0},{label:"白",value:"#ffffff"},{label:"グレー1",value:"#efefef"},{label:"グレー2",value:"#d9d9d9"},{label:"グレー3",value:"#cccccc"},{label:"グレー4",value:"#b7b7b7"},{label:"グレー5",value:"#999999"},{label:"グレー6",value:"#666666"},{label:"グレー7",value:"#434343"},{label:"黒",value:"#000000"},{label:"薄茶",value:"#E6B8AF"},{label:"薄赤",value:"#F4CCCC"},{label:"薄橙",value:"#FCE5CD"},{label:"薄黄",value:"#FFF2CC"},{label:"薄緑",value:"#D9EAD3"},{label:"薄青緑",value:"#D0E0E3"},{label:"薄青",value:"#C9DAF8"},{label:"薄青紫",value:"#CFE2F3"},{label:"薄紫",value:"#D9D2E9"},{label:"薄赤紫",value:"#EAD1DC"},{label:"茶",value:"#DD7E6B"},{label:"赤",value:"#EA9999"},{label:"橙",value:"#F9CB9C"},{label:"黄",value:"#FFE599"},{label:"緑",value:"#B6D7A8"},{label:"青緑",value:"#A2C4C9"},{label:"青",value:"#A4C2F4"},{label:"青紫",value:"#9FC5E8"},{label:"紫",value:"#B4A7D6"},{label:"赤紫",value:"#D5A6BD"}],kt=({onColorSelect:e,selectedColor:t,readOnly:n=!1})=>r.jsx("div",{className:te.palette,children:vn.map((s,o)=>{const l=s.value===void 0,i=s.value===t,a=l?{}:{backgroundColor:s.value};return r.jsx("button",{type:"button",className:`${te.paletteButton} ${l?te.transparentPaletteButton:""} ${i?te.selected:""}`,onClick:()=>e(s.value),disabled:n,title:s.label,"aria-label":s.label,style:a},s.value??`undefined-${o}`)})});kt.displayName="ColorPalette";const Br="_input_14n56_5",Vr={input:Br},ie=({value:e,onChange:t,readOnly:n=!1,min:s,max:o,step:l,integer:i,placeholder:a,width:c,height:d,config:f,onBlur:x})=>{const b=s??(f==null?void 0:f.min)??1,v=o??(f==null?void 0:f.max),E=l??(f==null?void 0:f.step)??1,y=i??(f==null?void 0:f.integer)??!1,h=a??(f==null?void 0:f.placeholder),p=c??(f==null?void 0:f.width),m=d??(f==null?void 0:f.height),w=u.useCallback(D=>{const A=D.target.value;if(A===""){t(void 0);return}let $=Number.parseFloat(A);Number.isNaN($)||(y&&($=Math.round($)),b!==void 0&&$<b&&($=b),v!==void 0&&$>v&&($=v),t($))},[t,b,v,y]),_={};return p!==void 0&&(_.width=`${p}px`),m!==void 0&&(_.height=`${m}px`,_.paddingTop=0,_.paddingBottom=0),r.jsx("input",{type:"number",className:Vr.input,style:_,value:e??"",onChange:w,onBlur:x,disabled:n,min:b,max:v,step:E,placeholder:h})};ie.displayName="NumberInput";const Pt=({rgba:e,onChange:t,readOnly:n=!1})=>r.jsxs("div",{className:te.rgbaInputs,children:[r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"R"}),r.jsx(ie,{value:e.r,onChange:s=>t("r",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"G"}),r.jsx(ie,{value:e.g,onChange:s=>t("g",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"B"}),r.jsx(ie,{value:e.b,onChange:s=>t("b",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"A"}),r.jsx(ie,{value:Math.round(e.a*100),onChange:s=>t("a",s!==void 0?s/100:void 0),min:0,max:100,step:1,integer:!0,width:48,readOnly:n})]})]});Pt.displayName="RGBAInputs";const B={GRID_CANVAS:10,MARGIN_OVERLAY:20,GRID_OVERLAY:30,BORDER_OVERLAY:40,BLOCK_LAYER_MIN:100,BLOCK_LAYER_MAX:999999,BLOCK_LAYER_STEP:100,ERROR_BORDER:11e5,ERROR_TOOLTIP:12e5,ERROR_HIGHLIGHT:13e5,SELECT_BLOCK:2e6,INTERACTION_LAYER_BASE:21e5,BLOCK_GHOST:22e5,HOVER_OUTLINE:23e5,EDIT_BLOCK:24e5,BLOCK_SELECT_BORDER:25e5,BLOCK_HANDLES:26e5,GRID_GHOST:27e5,GRID_HANDLES:28e5,RUBBER_BAND:29e5,PROPERTY_PANEL:31e5,PALETTE:32e5,TOOLTIP:33e5,DROPDOWN:34e5,CONTEXT_MENU:35e5,MODAL:36e5,DEBUG:1e7},he={BG:10,CONTENT:50,GUIDE:70,BORDER:80},St=({isOpen:e,onClose:t,rgba:n,onRgbaChange:s,onColorSelect:o,selectedColor:l,readOnly:i=!1})=>{const a=u.useRef(null);return u.useEffect(()=>{if(!e)return;const c=d=>{a.current&&!a.current.contains(d.target)&&t()};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[e,t]),e?r.jsxs("div",{className:te.popover,ref:a,style:{zIndex:B.DROPDOWN},children:[r.jsx(kt,{onColorSelect:o,selectedColor:l,readOnly:i}),r.jsx(Pt,{rgba:n,onChange:s,readOnly:i})]}):null};St.displayName="ColorPickerPopover";const ze=({value:e,onChange:t,readOnly:n=!1,showTextInput:s=!0,allowUndefined:o,placeholder:l,width:i,height:a,config:c})=>{const d=o??(c==null?void 0:c.allowUndefined)??!0,f=l??(d?"未設定":"#000000"),x=i??(c==null?void 0:c.width),b=a??(c==null?void 0:c.height),[v,E]=u.useState(!1),y=u.useRef(null),[h,p]=u.useState(()=>yt(e)??{r:0,g:0,b:0,a:1});u.useEffect(()=>{const N=yt(e);N&&p(N)},[e]);const m=u.useCallback(()=>{n||E(N=>!N)},[n]),[w,_]=u.useState(e?e.replace(/^#/,""):"");u.useEffect(()=>{_(e?e.replace(/^#/,""):"")},[e]);const D=u.useCallback(N=>{const I=N.target.value;/^[0-9A-Fa-f]*$/.test(I)&&_(I)},[]),A=u.useCallback(N=>{if(N===""&&d){t(void 0);return}/^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(N)?t(`#${N}`):_(e?e.replace(/^#/,""):"")},[t,d,e]),$=u.useCallback(N=>{A(N.target.value)},[A]),j=u.useCallback(N=>{N.key==="Enter"&&(N.preventDefault(),A(N.currentTarget.value),N.currentTarget.blur())},[A]),M=u.useCallback(N=>{t(N)},[t]),R=u.useCallback((N,I)=>{if(I===void 0)return;const k={...h,[N]:I};p(k),t(bn(k))},[h,t]),O=e??"未設定",C={};e&&(C.background=e);const L={};return x!==void 0?L.width=`${x}px`:L.width="100%",b!==void 0&&(L.height=`${b}px`),r.jsxs("div",{className:te.container,style:L,ref:y,children:[r.jsx("button",{type:"button",className:te.colorButton,onClick:m,disabled:n,title:O,"aria-label":"カラーピッカーを開く",style:C}),s&&r.jsxs("div",{className:te.textInputWrapper,children:[r.jsx("span",{className:te.textInputPrefix,children:"#"}),r.jsx("input",{type:"text",className:te.textInput,value:w,onChange:D,onKeyDown:j,onBlur:$,disabled:n,placeholder:f,maxLength:8})]}),r.jsx(St,{isOpen:v,onClose:()=>E(!1),rgba:h,onRgbaChange:R,onColorSelect:M,selectedColor:e,readOnly:n})]})};ze.displayName="ColorPicker";const Ur="_container_1n9lj_5",Fr="_valueInput_1n9lj_23",zr="_unitSelect_1n9lj_45",vt={container:Ur,valueInput:Fr,unitSelect:zr},ne=e=>{const{value:t,onChange:n,readOnly:s=!1,config:o}=e,l=e.allowedUnits??(o==null?void 0:o.allowedUnits),i=e.min??(o==null?void 0:o.min),a=e.max??(o==null?void 0:o.max),c=e.step??(o==null?void 0:o.step)??1,d=e.placeholder??(o==null?void 0:o.placeholder),f=e.width??(o==null?void 0:o.width),x=e.height??(o==null?void 0:o.height),b=(t==null?void 0:t.unit)??(l==null?void 0:l[0]),v=u.useCallback(m=>{const w=m.target.value;if(w==="")return;let _=Number.parseFloat(w);if(Number.isNaN(_))return;const D=i??1;_<D&&(_=D),a!==void 0&&_>a&&(_=a),n({value:_,unit:(t==null?void 0:t.unit)??b})},[t,n,b,i,a]),E=u.useCallback(m=>{const w=m.target.value;n({value:(t==null?void 0:t.value)??0,unit:w})},[t,n]),y=(t==null?void 0:t.value)??"",h=(t==null?void 0:t.unit)??b??"",p={};return f!==void 0?p.width=`${f}px`:p.width="100%",x!==void 0&&(p.height=`${x}px`),r.jsxs("div",{className:vt.container,style:p,children:[r.jsx("input",{type:"number",className:vt.valueInput,value:y,onChange:v,placeholder:d,min:i??1,max:a,step:c,readOnly:s,disabled:s}),r.jsx("select",{className:vt.unitSelect,value:h,onChange:E,disabled:s||!l||l.length<=1,children:l?l.map(m=>r.jsx("option",{value:m,children:m},m)):r.jsx("option",{value:h,children:h})})]})},Wr="_container_1bfk3_6",Yr="_scrollArea_1bfk3_23",Hr="_emptyState_1bfk3_31",gt={container:Wr,scrollArea:Yr,emptyState:Hr},At=({children:e,emptyMessage:t,className:n})=>r.jsx("div",{className:`${gt.container} ${n||""}`,children:e?r.jsx("div",{className:gt.scrollArea,children:e}):t&&r.jsx("div",{className:gt.emptyState,children:t})}),Kr="_root_qs6t8_3",Xr="_list_qs6t8_11",qr="_trigger_qs6t8_26",Zr="_content_qs6t8_71",lt={root:Kr,list:Xr,trigger:qr,content:Zr},at=u.createContext(void 0),Lt=({defaultValue:e,value:t,onValueChange:n,children:s,variant:o="default",className:l=""})=>{const[i,a]=u.useState(e),c=t??i,d=f=>{a(f),n==null||n(f)};return r.jsx(at.Provider,{value:{value:c,onChange:d,variant:o},children:r.jsx("div",{className:`${lt.root} ${l}`,"data-variant":o,children:s})})},Ot=({children:e,className:t="",width:n,height:s,style:o})=>{const l=u.useContext(at);if(!l)throw new Error("TabsList must be used within a Tabs component");const{variant:i}=l,a={...o};return n!==void 0&&(a.width=`${n}px`),s!==void 0&&(a.height=`${s}px`),r.jsx("div",{className:`${lt.list} ${t}`,"data-variant":i,style:a,children:e})},ye=({value:e,children:t,className:n="",disabled:s=!1,width:o,height:l,style:i})=>{const a=u.useContext(at);if(!a)throw new Error("TabsTrigger must be used within a Tabs component");const{value:c,onChange:d,variant:f}=a,x=c===e,b={...i};return o!==void 0&&(b.width=`${o}px`),l!==void 0&&(b.height=`${l}px`),r.jsx("button",{className:`${lt.trigger} ${n}`,"data-state":x?"active":"inactive","data-variant":f,onClick:()=>d(e),disabled:s,type:"button",style:b,children:t})},Ee=({value:e,children:t,className:n=""})=>{const s=u.useContext(at);if(!s)throw new Error("TabsContent must be used within a Tabs component");const{value:o}=s;return o!==e?null:r.jsx("div",{className:`${lt.content} ${n}`,children:t})},Jr="_input_9unrj_5",Qr={input:Jr},Se=({value:e,onChange:t,readOnly:n=!1,placeholder:s,maxLength:o,multiline:l,rows:i,width:a,height:c,config:d,onBlur:f})=>{const x=s??(d==null?void 0:d.placeholder),b=o??(d==null?void 0:d.maxLength),v=l??(d==null?void 0:d.multiline)??!1,E=i??(d==null?void 0:d.rows)??3,y=u.useCallback(m=>{const w=m.target.value;t(w)},[t]),h={};a!==void 0?h.width=`${a}px`:h.width="100%",c!==void 0&&(h.height=`${c}px`);const p={className:Qr.input,style:h,value:e??"",onChange:y,disabled:n,placeholder:x,maxLength:b};return v?r.jsx("textarea",{...p,rows:E}):r.jsx("input",{...p,type:"text",onBlur:f})};Se.displayName="TextInput";const eo=["mm","cm","fr","inch","pt","px","%"],to=["mm","cm","pt","inch","px"],no=["mm","cm","inch"],ro=["mm","cm","fr","inch","pt","px"],gn=["px","pt","mm"],wn=["px","pt","mm"],Te=["mm","pt","px","%"],Et=["mm","cm","inch","pt","px","%"],_n={isIndividual:{defaultValue:!1,label:"個別に設定",group:"余白",Component:xe,description:"上下左右の余白を個別に設定します"},all:{defaultValue:{value:10,unit:"px"},label:"全方向",group:"余白",Component:ne,config:{allowedUnits:Te,min:0},condition:e=>!e.isIndividual},top:{defaultValue:{value:10,unit:"px"},label:"上",group:"余白",Component:ne,config:{allowedUnits:Te,min:0},condition:e=>e.isIndividual===!0},right:{defaultValue:{value:10,unit:"px"},label:"右",group:"余白",Component:ne,config:{allowedUnits:Te,min:0},condition:e=>e.isIndividual===!0},bottom:{defaultValue:{value:10,unit:"px"},label:"下",group:"余白",Component:ne,config:{allowedUnits:Te,min:0},condition:e=>e.isIndividual===!0},left:{defaultValue:{value:10,unit:"px"},label:"左",group:"余白",Component:ne,config:{allowedUnits:Te,min:0},condition:e=>e.isIndividual===!0}},oo={...xn,..._n},so={fontSize:{defaultValue:{value:14,unit:"pt"},label:"フォントサイズ",group:"フォント",description:"テキストのフォントサイズを設定します",Component:ne,config:{allowedUnits:wn,min:1,step:1}},fontFamily:{defaultValue:"sans-serif",label:"フォント",group:"フォント",Component:we,config:{placeholder:"フォントを選択",options:[{label:"ゴシック体",value:"sans-serif"},{label:"明朝体",value:"serif"},{label:"等幅",value:"monospace"},{label:"Arial",value:"Arial, sans-serif"},{label:"Times New Roman",value:"'Times New Roman', serif"}]}},color:{defaultValue:void 0,label:"文字色",group:"フォント",Component:ze,config:{allowUndefined:!0}},fontWeight:{defaultValue:!1,label:"太字",group:"フォント",description:"テキストを太字にします",Component:xe},italic:{defaultValue:!1,label:"斜体",group:"フォント",description:"テキストを斜体にします",Component:xe},underline:{defaultValue:!1,label:"下線",group:"フォント",description:"テキストに下線を引きます",Component:xe},lineThrough:{defaultValue:!1,label:"取り消し線",group:"フォント",description:"テキストに取り消し線を引きます",Component:xe},lineHeight:{defaultValue:1.2,label:"行の高さ",group:"フォント",description:"行の高さを設定します(1.0〜3.0)",Component:ie,config:{min:1,max:3,step:.1}}};function io(e){return e.reduce((t,n)=>(t[n.kind]=n,t),{})}var je=(e=>(e.Contain="contain",e.Cover="cover",e.Fill="fill",e.None="none",e.ScaleDown="scale-down",e))(je||{});const lo={objectFit:{defaultValue:je.Contain,label:"表示方法",group:"画像",description:"画像のサイズが枠と合わない場合の表示方法を設定します",Component:we,config:{options:[{label:"全体を表示",value:je.Contain},{label:"枠を埋める/切り抜き",value:je.Cover},{label:"引き伸ばす/縮小する",value:je.Fill},{label:"元のサイズ",value:je.None},{label:"縮小のみ",value:je.ScaleDown}]}},alt:{defaultValue:"",label:"代替テキスト",group:"画像",description:"画像が表示できない場合に表示されるテキスト",Component:Se,config:{placeholder:"画像の説明"}}};var Me=(e=>(e.Normal="normal",e.BreakWord="break-word",e.BreakAll="break-all",e))(Me||{}),ke=(e=>(e.Normal="normal",e.NoWrap="nowrap",e.Pre="pre",e.PreWrap="pre-wrap",e.PreLine="pre-line",e))(ke||{});const ao={multiline:{defaultValue:!1,label:"複数行モード",group:"設定",Component:xe,config:{label:"有効にする"}},wordWrap:{defaultValue:Me.Normal,label:"単語の折り返し",group:"設定",Component:we,config:{options:[{label:"通常",value:Me.Normal},{label:"単語で改行",value:Me.BreakWord},{label:"強制改行",value:Me.BreakAll}]},condition:e=>e.multiline===!0},whiteSpace:{defaultValue:ke.Normal,label:"空白文字の扱い",group:"設定",Component:we,config:{options:[{label:"通常",value:ke.Normal},{label:"折り返しなし",value:ke.NoWrap},{label:"そのまま表示",value:ke.Pre}]},condition:e=>e.multiline===!0}},co={placeholder:{defaultValue:void 0,label:"プレースホルダー",group:"設定",description:"入力欄に表示するプレースホルダーテキストを設定します",Component:Se,config:{placeholder:"例: テキストを入力してください"}}},uo={width:{defaultValue:void 0,label:"幅",group:"サイズ",description:"要素の幅を設定します",Component:ne,config:{min:0,allowedUnits:Et,placeholder:"auto"}},height:{defaultValue:void 0,label:"高さ",group:"サイズ",description:"要素の高さを設定します",Component:ne,config:{min:0,allowedUnits:Et,placeholder:"auto"}}},yn=e=>{const t={};return Object.entries(e.properties).forEach(([n,s])=>{s!==!1&&typeof s=="object"&&s!==null&&"defaultValue"in s&&(t[n]=s.defaultValue)}),t};function En(e){const t=Date.now(),n=Math.random().toString(36).slice(2);return`${e}_${t}_${n}`}function Ie(e,t,n){const s=yn(e);return{id:En(e.kind),kind:e.kind,layout:{x:t.x,y:t.y,w:t.w,h:t.h},style:{},behavior:{},props:{...s,...n}}}const ho={required:{defaultValue:!1,label:"必須項目",group:"バリデーション",description:"この項目を必須入力にします",Component:xe,config:{label:"必須にする"}},minLength:{defaultValue:void 0,label:"最小文字数",group:"バリデーション",description:"入力可能な最小文字数を設定します",Component:ie,config:{min:0,integer:!0,placeholder:"制限なし"}},maxLength:{defaultValue:void 0,label:"最大文字数",group:"バリデーション",description:"入力可能な最大文字数を設定します",Component:ie,config:{min:0,integer:!0,placeholder:"制限なし"}},pattern:{defaultValue:void 0,label:"入力パターン (正規表現)",group:"バリデーション",description:"入力値を検証する正規表現パターンを設定します",Component:Se,config:{placeholder:"例: ^[0-9]+$"},disableInMultiSelection:!0}};var ae=(e=>(e.ADD="add",e.UPDATE="update",e.DELETE="delete",e.MOVE="move",e.RESIZE="resize",e.DUPLICATE="duplicate",e.PASTE="paste",e))(ae||{});const jn={cols:Array.from({length:12}).map(()=>({value:1,unit:"fr"})),rows:Array.from({length:16}).map(()=>({value:1,unit:"fr"}))};var de=(e=>(e.SOLID="solid",e.DASHED="dashed",e.DOTTED="dotted",e))(de||{});const W=96;function se(e,t){if(e<=0){const n=t??"Value";throw new Error(`${n} must be positive (> 0): got ${e}`)}}function Ne(e,t){if(e<0){const n=t??"Value";throw new Error(`${n} must be non-negative (>= 0): got ${e}`)}}function Nn(e,t,n,s){if(e<t||e>n){const o=s??"Value";throw new Error(`${o} must be between ${t} and ${n}: got ${e}`)}}function ct(e,t){if(!Number.isInteger(e)){const n=t??"Value";throw new Error(`${n} must be an integer: got ${e}`)}}function mo(e,t){if(!Number.isFinite(e)){const n=t??"Value";throw new Error(`${n} must be a finite number: got ${e}`)}}const fo=25.4,po=2.54,xo=72,V={_assertDpi(e){se(e,"DPI"),ct(e,"DPI")},fromMm(e,t=W){return V._assertDpi(t),Ne(e,"Millimeter value"),e*t/fo},fromCm(e,t=W){return V._assertDpi(t),Ne(e,"Centimeter value"),e*t/po},fromInch(e,t=W){return V._assertDpi(t),Ne(e,"Inch value"),e*t},fromPt(e,t=W){return V._assertDpi(t),Ne(e,"Point value"),e*t/xo},fromPx(e,t=W){return V._assertDpi(t),Ne(e,"Pixel value"),e*t/W},fromDim(e,t=W,n){switch(V._assertDpi(t),Ne(e.value,"Dimension value"),e.unit){case"mm":return V.fromMm(e.value,t);case"cm":return V.fromCm(e.value,t);case"inch":return V.fromInch(e.value,t);case"pt":return V.fromPt(e.value,t);case"px":return V.fromPx(e.value,t);case"%":if(n===void 0)throw new Error("Base size must be defined for percentage values.");return e.value/100*n;case"fr":throw new Error(`Cannot convert ${e.unit} to px. Use physical units only.`);default:{const s=e.unit;throw new Error(`Unsupported unit: ${s}`)}}}},Pe=e=>{if(!(e!=null&&e.width)||!(e!=null&&e.type))return;const t=e.width.value;if(t!==0){if(e.type===de.DASHED)return`${t*4} ${t*2}`;if(e.type===de.DOTTED)return`${t*1} ${t*2}`}};class Ae{constructor(t){this.style=t}get top(){return this.style.top?{...this.style.all,...this.style.top}:this.style.all}get right(){return this.style.right?{...this.style.all,...this.style.right}:this.style.all}get bottom(){return this.style.bottom?{...this.style.all,...this.style.bottom}:this.style.all}get left(){return this.style.left?{...this.style.all,...this.style.left}:this.style.all}get hasAnyBorder(){return!!(this.top||this.right||this.bottom||this.left)}getTopSVGProps(t,n=W){const s=this.top;return s?{x1:0,y1:0,x2:t,y2:0,stroke:s.color,strokeWidth:V.fromDim(s.width,n),strokeDasharray:Pe(s),vectorEffect:"non-scaling-stroke","data-edge":"top"}:null}getRightSVGProps(t,n,s=W){const o=this.right;return o?{x1:t,y1:0,x2:t,y2:n,stroke:o.color,strokeWidth:V.fromDim(o.width,s),strokeDasharray:Pe(o),vectorEffect:"non-scaling-stroke","data-edge":"right"}:null}getBottomSVGProps(t,n,s=W){const o=this.bottom;return o?{x1:0,y1:n,x2:t,y2:n,stroke:o.color,strokeWidth:V.fromDim(o.width,s),strokeDasharray:Pe(o),vectorEffect:"non-scaling-stroke","data-edge":"bottom"}:null}getLeftSVGProps(t,n=W){const s=this.left;return s?{x1:0,y1:0,x2:0,y2:t,stroke:s.color,strokeWidth:V.fromDim(s.width,n),strokeDasharray:Pe(s),vectorEffect:"non-scaling-stroke","data-edge":"left"}:null}}var ce=(e=>(e.FORM="Form",e.EDIT="Edit",e.VIEW="View",e))(ce||{}),pe=(e=>(e.A4="A4",e.B5="B5",e.A3="A3",e.LETTER="Letter",e.LEGAL="Legal",e.CUSTOM="Custom",e))(pe||{});const Gt={A4:{preset:"A4",width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}},A3:{preset:"A3",width:{value:297,unit:"mm"},height:{value:420,unit:"mm"}},B5:{preset:"B5",width:{value:182,unit:"mm"},height:{value:257,unit:"mm"}},Letter:{preset:"Letter",width:{value:8.5,unit:"inch"},height:{value:11,unit:"inch"}},Legal:{preset:"Legal",width:{value:8.5,unit:"inch"},height:{value:14,unit:"inch"}},Custom:{preset:"Custom",width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}}},In={top:{value:10,unit:"mm"},right:{value:10,unit:"mm"},bottom:{value:10,unit:"mm"},left:{value:10,unit:"mm"}},Dn={size:Gt.A4,margin:In},bo={paper:Dn,grid:jn,blocks:[]};var $n=(e=>(e.ERROR="error",e.WARNING="warning",e.INFO="info",e))($n||{});const De=u.memo(({width:e,height:t,border:n,dpi:s=W,className:o=""})=>n.hasAnyBorder?r.jsxs("svg",{width:e,height:t,xmlns:"http://www.w3.org/2000/svg",className:o,style:{overflow:"visible"},children:[r.jsx("title",{children:"border SVG"}),n.top&&r.jsx("line",{...n.getTopSVGProps(e,s)}),n.right&&r.jsx("line",{...n.getRightSVGProps(e,t,s)}),n.bottom&&r.jsx("line",{...n.getBottomSVGProps(e,t,s)}),n.left&&r.jsx("line",{...n.getLeftSVGProps(t,s)})]}):null);De.displayName="BorderRenderer";function Tn(e){const t=B.BLOCK_LAYER_MIN+e*B.BLOCK_LAYER_STEP;return t>=B.BLOCK_LAYER_MAX?B.BLOCK_LAYER_MAX:t}function We(e,t){const n=Math.min(Math.max(0,t),B.BLOCK_LAYER_STEP-1);return e+n}function vo(){return Math.floor((B.BLOCK_LAYER_MAX-B.BLOCK_LAYER_MIN)/B.BLOCK_LAYER_STEP)}const Cn=u.memo(({blockSizePx:e,borderStyle:t,blockZIndex:n,subZIndex:s=he.BORDER,visible:o=!0,dpi:l=W,className:i=""})=>{const a=u.useMemo(()=>{if(t)return new Ae(t)},[t]);if(!o||!a||!a.hasAnyBorder)return null;const c=We(n,s),d={position:"absolute",left:0,top:0,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:i,style:d,"data-testid":"block-border",children:r.jsx(De,{width:e.width,height:e.height,border:a,dpi:l})})}),Rn=u.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=he.BG,backgroundColor:s="transparent",className:o=""})=>{const l=We(t,n),i={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:s,pointerEvents:"none",zIndex:l};return r.jsx("div",{className:o,style:i,role:"presentation","aria-label":"Block background","data-testid":"block-canvas"})}),Mn={color:"#cccccc",width:{value:1,unit:"pt"},type:de.SOLID},ut={all:Mn},kn=u.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=he.GUIDE,borderStyle:s=ut,visible:o=!0,dpi:l=W,className:i=""})=>{const a=u.useMemo(()=>{if(s)return new Ae(s)},[s]);if(!o||!a||!a.hasAnyBorder)return null;const c=We(t,n),d={position:"absolute",left:0,top:0,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:i,style:d,"data-testid":"block-base-border",children:r.jsx(De,{width:e.width,height:e.height,border:a,dpi:l})})}),go=({id:e,plugin:t,props:n,value:s,onChange:o,onBlur:l,readOnly:i,mode:a,blockSizePx:c,blockZIndex:d,subZIndex:f=he.CONTENT,validationState:x,className:b=""},v)=>{const E=u.useRef(null);u.useImperativeHandle(v,()=>({focus:()=>{var w;return(w=E.current)==null?void 0:w.focus()}}),[]);const y=We(d,f),h={position:"absolute",inset:0,width:`${c.width}px`,height:`${c.height}px`,zIndex:y,pointerEvents:"auto"},p={id:e,props:n,value:s,onChange:o??(()=>{}),onBlur:l,readOnly:i,mode:a,dimensions:{widthPx:c.width,heightPx:c.height},validationState:x},m=t.Renderer;return r.jsx("div",{className:b,style:h,"data-testid":"block-renderer","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(m,{ref:E,...p})})},wo=u.forwardRef(go),Ye=u.memo(wo);function Bt(e,t){return{position:"absolute",left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,zIndex:t==null?void 0:t.zIndex,pointerEvents:(t==null?void 0:t.pointerEvents)??"auto"}}const Vt=u.memo(u.forwardRef(({block:e,plugin:t,blockRectPx:n,blockZIndex:s,mode:o,value:l,onValueChange:i,onValueBlur:a,showGuides:c=!0,showBorder:d=!0,blockSubZIndex:f={bg:he.BG,guide:he.GUIDE,content:he.CONTENT,border:he.BORDER},defaultGuideBorder:x=ut,dpi:b=W,className:v="",pointerEvents:E="none"},y)=>{var m,w,_,D;const h=Bt(n,{zIndex:s,pointerEvents:E}),p=u.useMemo(()=>({width:n.width,height:n.height}),[n.width,n.height]);return r.jsxs("div",{style:h,"data-block-id":e.id,className:v,children:[r.jsx(Rn,{blockSizePx:p,blockZIndex:s,backgroundColor:(m=e.style)==null?void 0:m.backgroundColor,subZIndex:f.bg}),c&&!((w=e.style)!=null&&w.border)&&r.jsx(kn,{blockSizePx:p,blockZIndex:s,subZIndex:f.guide,borderStyle:x,dpi:b}),r.jsx(Ye,{id:e.id,ref:y,plugin:t,props:e.props,value:l,onChange:i,onBlur:a,readOnly:o===ce.EDIT?((_=e.behavior)==null?void 0:_.readOnly)??!1:!0,mode:o,blockSizePx:p,blockZIndex:s,subZIndex:f.content}),r.jsx(Cn,{blockSizePx:p,blockZIndex:s,borderStyle:(D=e.style)==null?void 0:D.border,subZIndex:f.border,visible:d,dpi:b})]})}));Vt.displayName="BlockContainer";const He=u.memo(({blocks:e,pluginRegistry:t,mode:n,values:s,selectedBlockIds:o=[],getBlockRectPx:l,onValueChange:i,onValueBlur:a,showGuides:c=!0,showBorder:d=!0,blockSubZIndex:f={bg:he.BG,guide:he.GUIDE,content:he.CONTENT,border:he.BORDER},defaultGuideBorder:x=ut,dpi:b=W,className:v=""})=>{const E=u.useRef(new Map),y={position:"absolute",inset:0,pointerEvents:"none"};return r.jsx("div",{className:v,style:y,"data-testid":"block-layer",children:e.map((h,p)=>{const m=t[h.kind];if(!m)return null;const w=l(h),_=o.includes(h.id);let D=Tn(p);_&&(D=B.SELECT_BLOCK);const A=s[h.id]??h.initValue;return r.jsx(Vt,{ref:$=>{$?E.current.set(h.id,$):E.current.delete(h.id)},block:h,plugin:m,blockRectPx:w,blockZIndex:D,mode:n,value:A,onValueChange:i?$=>i(h.id,$):void 0,onValueBlur:$=>a==null?void 0:a(h.id,$),showGuides:c,showBorder:d,blockSubZIndex:f,defaultGuideBorder:x,dpi:b,pointerEvents:"none"},h.id)})})});He.displayName="BlockLayer";const Pn=u.memo(({contentPx:e,marginLeftPx:t,marginTopPx:n,borderStyle:s,visible:o=!0,dpi:l=W,zIndex:i=B.BORDER_OVERLAY,className:a=""})=>{const c=u.useMemo(()=>{if(s)return new Ae(s)},[s]);if(!o||!c||!c.hasAnyBorder)return null;const d={position:"absolute",left:`${t}px`,top:`${n}px`,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:i};return r.jsx("div",{className:a,style:d,"data-testid":"border-overlay",children:r.jsx(De,{width:e.width,height:e.height,border:c,dpi:l})})}),Sn=u.memo(({canvasPx:e,backgroundColor:t="#ffffff",boxShadow:n="0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:s=B.GRID_CANVAS,className:o})=>{const l={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:t,boxShadow:n,pointerEvents:"none",zIndex:s};return r.jsx("div",{className:o,style:l,role:"presentation","aria-label":"Paper background","data-testid":"grid-canvas"})}),_o="_label_vgaic_1",yo={label:_o},Eo="_editor_6szgo_5",jo="_input_6szgo_18",No="_select_6szgo_38",Io="_button_6szgo_54",Ze={editor:Eo,input:jo,select:No,button:Io};function An(e,t){const n=e.match(/^(\d+(?:\.\d+)?)([a-zA-Z%]+)$/);if(!n)throw new Error(`Invalid dimension string: ${e}`);const s=Number(n[1]),o=n[2];if(se(s,"Dimension value"),!t.includes(o))throw new Error(`Unit not allowed: ${o}`);return{value:s,unit:o}}function Do(e,t){return e.map(n=>An(n,t))}const $o=10,To=25.4,Co=.352778,Ro=.264583,Y={fromCm(e){return se(e,"Centimeter value"),e*$o},fromInch(e){return se(e,"Inch value"),e*To},fromPt(e){return se(e,"Point value"),e*Co},fromPx(e){return se(e,"Pixel value"),e*Ro},fromDim(e){switch(se(e.value,"Dimension value"),e.unit){case"mm":return e.value;case"cm":return Y.fromCm(e.value);case"inch":return Y.fromInch(e.value);case"pt":return Y.fromPt(e.value);case"px":return Y.fromPx(e.value);case"fr":case"%":throw new Error(`Cannot convert ${e.unit} to mm. Use physical units only.`);default:{const t=e.unit;throw new Error(`Unsupported unit: ${t}`)}}}};function Ln(e){return se(e.value,"Dimension"),`${e.value}${e.unit}`}function Mo(e){return e.map(Ln)}const ko=["fr","px","mm","cm","pt","inch"];function Po(e,t){if(t==="fr")return 1;switch(t){case"px":return e;case"mm":{const n=Y.fromPx(e);return Math.round(n*10)/10}case"cm":{const s=Y.fromPx(e)/10;return Math.round(s*100)/100}case"inch":{const s=Y.fromPx(e)/25.4;return Math.round(s*100)/100}case"pt":{const o=Y.fromPx(e)/25.4*72;return Math.round(o*10)/10}default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}const On=u.memo(({direction:e,dimension:t,currentPxSize:n,position:s,marginLeftPx:o,marginTopPx:l,onChange:i,onCancel:a})=>{const[c,d]=u.useState(t.value.toString()),[f,x]=u.useState(t.unit),b=u.useRef(null),v=u.useRef(null),E=e==="column"?{left:`${o+s}px`,top:`${l+24}px`,transform:"translateX(-50%)"}:{left:`${o+24}px`,top:`${l+s}px`,transform:"translateY(-50%)"};u.useEffect(()=>{var m,w;(m=b.current)==null||m.focus(),(w=b.current)==null||w.select()},[]),u.useEffect(()=>{const m=w=>{v.current&&!v.current.contains(w.target)&&a()};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[a]);const y=()=>{const m=Number.parseFloat(c);!Number.isNaN(m)&&m>=.1?i({unit:f,value:m}):a()},h=m=>{m.key==="Enter"?(m.preventDefault(),y()):m.key==="Escape"&&(m.preventDefault(),a())},p=m=>{const w=m.target.value;x(w);const _=Po(n,w);d(_.toString())};return r.jsxs("div",{ref:v,className:Ze.editor,style:E,"data-testid":`grid-unit-editor-${e}`,children:[r.jsx("input",{ref:b,type:"number",className:Ze.input,value:c,onChange:m=>d(m.target.value),onKeyDown:h,min:"0.1",step:f==="fr"?"0.1":"1"}),r.jsx("select",{className:Ze.select,value:f,onChange:p,children:ko.map(m=>r.jsx("option",{value:m,children:m},m))}),r.jsx("button",{type:"button",className:Ze.button,onClick:y,title:"確定",children:"✓"})]})});On.displayName="GridUnitEditor";function So(e,t,n,s){if(t==="fr"){if(n!==void 0&&s!==void 0&&s>0){const o=e/s;return Math.round(n*o*100)/100}return 1}switch(t){case"px":return Math.round(e);case"mm":{const o=Y.fromPx(e);return Math.round(o*10)/10}case"cm":{const o=Y.fromPx(e);return Math.round(o/10*100)/100}case"inch":{const o=Y.fromPx(e);return Math.round(o/25.4*100)/100}case"pt":{const o=Y.fromPx(e);return Math.round(o/25.4*72*10)/10}default:{const o=t;throw new Error(`Unsupported unit: ${o}`)}}}const et=u.memo(({direction:e,index:t,dimension:n,position:s,currentPxSize:o,marginLeftPx:l,marginTopPx:i,isNearCursor:a,resizingPxSize:c,onDimensionChange:d})=>{const[f,x]=u.useState(!1);if(!a&&!f)return null;const b=e==="column"?{left:`${l+s}px`,top:`${i-20}px`,transform:"translateX(-50%)"}:{left:`${l-20}px`,top:`${i+s}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},v=()=>{x(!0)},E=m=>{d==null||d(e,t,m),x(!1)},y=()=>{x(!1)},p=c?(()=>{const m=So(c,n.unit,n.value,o);return n.unit==="fr"?`${m}fr`:`${m}${n.unit}`})():(m=>m.unit==="fr"?`${m.value}fr`:`${m.value}${m.unit}`)(n);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:yo.label,style:b,onDoubleClick:v,"data-testid":`grid-dimension-${e}-${t}`,"aria-label":`グリッド寸法: ${p}`,children:p})," ",f&&r.jsx(On,{direction:e,dimension:n,currentPxSize:o,position:s,marginLeftPx:l,marginTopPx:i,onChange:E,onCancel:y})]})});et.displayName="GridDimensionLabel";function Ao(e,t,n,s){let o="";for(const l of e)o+=`M ${l} 0 L ${l} ${s} `;for(const l of t)o+=`M 0 ${l} L ${n} ${l} `;return o}const Gn=u.memo(({gridPosPx:e,contentPx:t,marginLeftPx:n,marginTopPx:s,lineStyle:o,visible:l=!0,zIndex:i=B.GRID_OVERLAY,dpi:a=W,className:c=""})=>{const d=u.useMemo(()=>Ao(e.cols.slice(1,-1),e.rows.slice(1,-1),t.width,t.height),[e,t]);if(!l||!o)return null;const f=Pe(o),x=V.fromDim(o.width,a),b={position:"absolute",left:`${n}px`,top:`${s}px`,pointerEvents:"none",zIndex:i};return r.jsx("svg",{className:c,style:b,width:t.width,height:t.height,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Grid overlay lines",children:r.jsx("path",{d,stroke:o.color,strokeWidth:x,strokeDasharray:f,fill:"none"})})}),Lo="_handle_1mgtx_1",Oo="_dragging_1mgtx_19",wt={handle:Lo,dragging:Oo},tt=u.memo(({direction:e,index:t,position:n,marginLeftPx:s,marginTopPx:o,onResizeStart:l,onResize:i,onResizeEnd:a})=>{const[c,d]=u.useState(!1),f=12,x=f/2,b=e==="column"?{left:`${s+n-x}px`,top:`${o-x}px`,width:`${f}px`,height:`${f}px`,cursor:"col-resize"}:{left:`${s-x}px`,top:`${o+n-x}px`,width:`${f}px`,height:`${f}px`,cursor:"row-resize"},v=u.useCallback(E=>{E.stopPropagation(),E.preventDefault();const y=e==="column"?E.clientX:E.clientY;d(!0),l==null||l(e,t);const h=m=>{const _=(e==="column"?m.clientX:m.clientY)-y;i==null||i(e,t,_)},p=m=>{const _=(e==="column"?m.clientX:m.clientY)-y;d(!1),a==null||a(e,t,_),window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",p)};window.addEventListener("pointermove",h),window.addEventListener("pointerup",p)},[e,t,l,i,a]);return r.jsx("div",{className:`${wt.handle} ${wt[e]} ${c?wt.dragging:""}`,style:b,onPointerDown:v,"data-testid":`grid-resize-handle-${e}-${t}`})});tt.displayName="GridResizeHandle";const Bn=u.memo(({paperPx:e,visible:t=!0,marginColor:n,zIndex:s=B.MARGIN_OVERLAY,className:o=""})=>{if(!t)return null;const l={position:"absolute",inset:0,pointerEvents:"none",width:`${e.canvas.width}px`,height:`${e.canvas.height}px`,zIndex:s},i={position:"absolute",backgroundColor:n||"rgba(0, 0, 0, 0.05)",pointerEvents:"none"};return r.jsxs("div",{className:o,style:l,role:"presentation","aria-label":"Printable area margin","data-testid":"margin-overlay",children:[e.margin.top>0&&r.jsx("div",{"data-testid":"margin-top",style:{...i,top:0,left:0,width:"100%",height:`${e.margin.top}px`}}),e.margin.bottom>0&&r.jsx("div",{"data-testid":"margin-bottom",style:{...i,bottom:0,left:0,width:"100%",height:`${e.margin.bottom}px`}}),e.margin.left>0&&r.jsx("div",{"data-testid":"margin-left",style:{...i,left:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.left}px`}}),e.margin.right>0&&r.jsx("div",{"data-testid":"margin-right",style:{...i,right:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.right}px`}})]})}),dt=u.memo(({paperPx:e,gridPosPxs:t,gridDimensions:n,gridLineStyle:s,borderStyle:o,backgroundColor:l="#ffffff",boxShadow:i="0 2px 8px rgba(0, 0, 0, 0.1)",marginFillColor:a="rgba(0, 0, 0, 0.05)",showGridLines:c=!0,showMargins:d=!0,showBorder:f=!0,showResizeHandles:x=!1,showDimensionLabels:b=!1,onGridResize:v,onDimensionChange:E,className:y="",zIndex:h={}})=>{const[p,m]=u.useState(null),[w,_]=u.useState(null),[D,A]=u.useState(null),$=u.useRef(null);u.useEffect(()=>{const N=k=>{if(!$.current)return;const P=$.current.getBoundingClientRect();A({x:k.clientX-P.left,y:k.clientY-P.top})},I=k=>{if(!$.current)return;const P=$.current.getBoundingClientRect();(k.clientX<P.left||k.clientX>P.right||k.clientY<P.top||k.clientY>P.bottom)&&A(null)};return window.addEventListener("mousemove",N),window.addEventListener("mouseleave",I),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseleave",I)}},[]);const j=u.useMemo(()=>{if(!D)return!1;const N=e.content.width,I=e.content.height,k=e.margin.left,P=e.margin.top;return!(D.x>=k&&D.x<=k+N&&D.y>=P&&D.y<=P+I)},[D,e]),M=u.useCallback((N,I)=>{_({direction:N,index:I})},[]),R=u.useMemo(()=>{if(!p||!w)return null;const N=w.direction==="column"?t.cols:t.rows,I=w.index,k=N[I-1],P=p.position,F=k!==void 0?P-k:0,K=p.position,X=N[I+1],g=X!==void 0?X-K:0;return{direction:w.direction,prevIndex:I-1,prevSize:F,nextIndex:I,nextSize:g}},[p,w,t]),O=u.useCallback((N,I,k)=>{const P=N==="column"?t.cols:t.rows,F=P[I];if(F===void 0)return;const K=P[I-1],X=P[I+1],g=10;let T=k;if(K!==void 0){const S=K+g-F;T=Math.max(T,S)}if(X!==void 0){const S=X-g-F;T=Math.min(T,S)}m({direction:N,position:F+T})},[t]),C=u.useCallback((N,I,k)=>{const P=N==="column"?t.cols:t.rows,F=P[I];if(F===void 0){m(null);return}const K=P[I-1],X=P[I+1],g=10;let T=k;if(K!==void 0){const S=K+g-F;T=Math.max(T,S)}if(X!==void 0){const S=X-g-F;T=Math.min(T,S)}m(null),_(null),v==null||v(N,I,T)},[t,v]),L={position:"relative",width:"100%",height:"100%"};return r.jsxs("div",{ref:$,className:y,style:L,children:[r.jsx(Sn,{canvasPx:e.canvas,backgroundColor:l,boxShadow:i,zIndex:(h==null?void 0:h.canvas)??B.GRID_CANVAS,className:y}),d&&r.jsx(Bn,{paperPx:e,visible:d,marginColor:a,zIndex:(h==null?void 0:h.margin)??B.MARGIN_OVERLAY,className:y}),c&&r.jsx(Gn,{gridPosPx:t,contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,lineStyle:s,visible:c,zIndex:(h==null?void 0:h.grid)??B.GRID_OVERLAY,dpi:W,className:y}),f&&r.jsx(Pn,{contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,borderStyle:o,visible:f,dpi:W,zIndex:(h==null?void 0:h.border)??B.BORDER_OVERLAY,className:y}),x&&v&&r.jsxs(r.Fragment,{children:[t.cols.map((N,I)=>{if(I===0||I===t.cols.length-1)return null;const k=`col-${I}`;return r.jsx(tt,{direction:"column",index:I,position:N,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:M,onResize:O,onResizeEnd:C},k)}),t.rows.map((N,I)=>{if(I===0||I===t.rows.length-1)return null;const k=`row-${I}`;return r.jsx(tt,{direction:"row",index:I,position:N,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:M,onResize:O,onResizeEnd:C},k)})]}),b&&n&&r.jsxs(r.Fragment,{children:[n.cols.map((N,I)=>{const k=t.cols[I],P=t.cols[I+1];if(k===void 0||P===void 0)return null;const F=(w==null?void 0:w.direction)==="column"&&(w.index===I||w.index===I+1);let K;R&&R.direction==="column"&&(R.prevIndex===I?K=R.prevSize:R.nextIndex===I&&(K=R.nextSize));const X=(k+P)/2,g=P-k,T=`col-dim-${I}`;return r.jsx(et,{direction:"column",index:I,dimension:N,position:X,currentPxSize:g,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:j||F,resizingPxSize:K,onDimensionChange:E},T)})," ",n.rows.map((N,I)=>{const k=t.rows[I],P=t.rows[I+1];if(k===void 0||P===void 0)return null;const F=(w==null?void 0:w.direction)==="row"&&(w.index===I||w.index===I+1),K=(k+P)/2,X=P-k,g=`row-dim-${I}`;return r.jsx(et,{direction:"row",index:I,dimension:N,position:K,currentPxSize:X,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:j||F,onDimensionChange:E},g)})]}),p&&r.jsx("div",{style:{position:"absolute",left:p.direction==="column"?e.margin.left+p.position:e.margin.left,top:p.direction==="row"?e.margin.top+p.position:e.margin.top,width:p.direction==="column"?"2px":e.content.width,height:p.direction==="row"?"2px":e.content.height,backgroundColor:"#3b82f6",opacity:.5,pointerEvents:"none",zIndex:B.GRID_GHOST}})]})});class Go{constructor(){pt(this,"state",null);pt(this,"listeners",[])}start(t,n){this.state={kind:t,defaultSize:n},this.notify()}end(){this.state=null,this.notify()}get(){return this.state}subscribe(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter(n=>n!==t)}}notify(){for(const t of this.listeners)t(this.state)}}const nt=new Go;function jt(e,t,n,s){if(t<0||t>=e.length)return e;const o=[...e],l=o[t],i=o[t+1];return!l||!i?e:l.unit==="fr"&&i.unit==="fr"?Bo(o,t,n,s):l.unit!=="fr"&&i.unit!=="fr"?Vo(o,t,n):l.unit==="fr"&&i.unit!=="fr"?mn(o,t,n,"next",s):mn(o,t,n,"current",s)}function Bo(e,t,n,s){const o=e[t],l=e[t+1];if(!o||!l)return e;const i=e.reduce((E,y)=>y.unit==="fr"?E+y.value:E,0),a=s/i,c=o.value*a,d=l.value*a,f=Math.max(10,c+n),x=Math.max(10,d-n),b=f/a,v=x/a;return e[t]={...o,value:Math.round(b*100)/100},e[t+1]={...l,value:Math.round(v*100)/100},e}function Vo(e,t,n){const s=e[t],o=e[t+1];if(!s||!o)return e;const l=V.fromDim(s),i=V.fromDim(o),a=Math.max(10,l+n),c=Math.max(10,i-n);return e[t]={...s,value:rt(a,s.unit)},e[t+1]={...o,value:rt(c,o.unit)},e}function mn(e,t,n,s,o){const l=e[t],i=e[t+1];if(!l||!i)return e;let a=0,c=0;for(const x of e)x.unit==="fr"?a+=x.value:c+=V.fromDim(x);const d=o-c,f=a>0?d/a:0;if(s==="next"){const x=V.fromDim(i),b=Math.max(10,x-n);e[t+1]={...i,value:rt(b,i.unit)};const v=b-x,E=d-v,y=l.value*f,h=Math.max(10,y+n),p=a>0?h/E*a:1;e[t]={...l,value:Math.round(p*100)/100}}else{const x=V.fromDim(l),b=Math.max(10,x+n);e[t]={...l,value:rt(b,l.unit)};const v=b-x,E=d-v,y=i.value*f,h=Math.max(10,y-n),p=a>0?h/E*a:1;e[t+1]={...i,value:Math.round(p*100)/100}}return e}function rt(e,t){switch(t){case"px":return Math.round(e);case"mm":{const n=Y.fromPx(e);return Math.round(n*10)/10}case"cm":{const n=Y.fromPx(e);return Math.round(n/10*100)/100}case"inch":{const n=Y.fromPx(e);return Math.round(n/25.4*100)/100}case"pt":{const n=Y.fromPx(e);return Math.round(n/25.4*72*10)/10}case"fr":return 1;default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}function Vn(e){if(e.length===0)return[];const t=[];let n=0;for(const s of e){se(s,"Pixel value");const o=s+n,l=Math.round(o);t.push(l),n=o-l}return t}const Uo=8,Fo=32,zo=64,Wo=512,fn=(e,t,n)=>Math.min(Math.max(e,t),n);function Nt(e){const t=e.length-1,n=t>=1?e[t]??0:0,s=e.length>=1?n/t:0,o=fn(Math.ceil(Math.log2(t+1)),Uo,Fo),l=fn(s*2,zo,Wo);return{step:o,windowPx:l}}function Qe(e,t){const n=t.length-1;if(n<=0||t[0]===void 0||e<t[0]||t[n]===void 0)return-1;if(e>=t[n])return n-1;let s=1,o=n;for(;s<=o;){const l=s+o>>>1,i=t[l];if(i===void 0){o=l-1;continue}i<=e?s=l+1:o=l-1}return s-1}function It(e,t,n){const s=e.length-1;let o=0;return l=>{if(s<=0||e[0]===void 0||l<e[0]||e[s]===void 0)return-1;if(l>=e[s])return s-1;const i=e[o],a=e[o+1];if(i===void 0||a===void 0)return-1;if(i<=l&&l<a)return o;const c=i-n,d=a+n;if(l<c||l>=d)return o=Qe(l,e),o;let f=0;const x=e[o+1];if(x!==void 0&&l>=x)for(;o+1<s;){const b=e[o+1];if(b===void 0||l<b)break;if(o++,++f>t)return o=Qe(l,e),o}else for(;o>0;){const b=e[o];if(b===void 0||l>=b)break;if(o--,++f>t)return o=Qe(l,e),o}return o}}function ot(e,t){if(e.length===0)return[];se(t,"Content size");let n=0,s=0;const o=e.map(a=>{if(se(a.value,"Grid dimension value"),a.unit==="fr")return n+=a.value,null;{const c=Y.fromDim(a);return s+=c,c}});if(n===0)return Nn(s,0,t,"Total fixed size"),o;const l=t-s;se(l,"Content size - fixed sizes");const i=l/n;return o.map((a,c)=>{const d=e[c];if(a!=null)return a;if(!d)throw new Error(`dims[${c}] is undefined`);return d.value*i})}function st(e,t=96){se(t,"DPI"),ct(t,"DPI");const n=e.map(o=>V.fromMm(o,t));return Vn(n)}function Yo(e,t,n){if(e.length===0)return[];se(n,"DPI"),ct(n,"DPI"),se(t,"Content size");const s=ot(e,t);return st(s,n)}function it(e){const t={};for(const[n,s]of Object.entries(e))if(s!=null)if(typeof s=="object"&&!Array.isArray(s)&&s!==null){const o=it(s);t[n]=o}else t[n]=s;return t}function Ho(e,t){const s={A4:{width:210,height:297},A3:{width:297,height:420},B4:{width:257,height:364},B5:{width:182,height:257},Letter:{width:215.9,height:279.4},Legal:{width:215.9,height:355.6}}[e];return t==="landscape"?{width:s.height,height:s.width}:s}function Un(e){e!=null&&e.title&&(document.title=e.title),e!=null&&e.removeScrollbars&&(document.body.style.overflow="hidden")}function Fn(e){e!=null&&e.restoreScrollbars&&(document.body.style.overflow="")}function Dt(e){Un({title:e==null?void 0:e.title,removeScrollbars:!0});const t=()=>{var s;(s=e==null?void 0:e.onBeforePrint)==null||s.call(e)},n=()=>{var s;(s=e==null?void 0:e.onAfterPrint)==null||s.call(e),Fn({restoreScrollbars:!0}),window.removeEventListener("beforeprint",t),window.removeEventListener("afterprint",n)};window.addEventListener("beforeprint",t),window.addEventListener("afterprint",n),window.print()}function Ko(e){if(typeof e!="object"||e===null)return!1;const t=e;if(typeof t.id!="string"||typeof t.kind!="string"||typeof t.layout!="object"||t.layout===null)return!1;const n=t.layout;return!(typeof n.x!="number"||typeof n.y!="number"||typeof n.w!="number"||typeof n.h!="number"||t.props!==void 0&&typeof t.props!="object")}function Xo(e){return e==="fr"||e==="px"||e==="%"}function pn(e){return Array.isArray(e)?e.every(t=>{if(typeof t!="object"||t===null)return!1;const n=t;return typeof n.value=="number"&&Xo(n.unit)}):!1}function qo(e){if(typeof e!="object"||e===null)return!1;const t=e;return pn(t.cols)&&pn(t.rows)}function Zo(e){if(typeof e!="object"||e===null)return!1;const t=e;if(typeof t.size!="object"||t.size===null)return!1;const n=t.size;if(typeof n.preset!="string"||typeof n.width!="object"||n.width===null)return!1;const s=n.width;if(typeof s.value!="number"||typeof s.unit!="string"||typeof n.height!="object"||n.height===null)return!1;const o=n.height;if(typeof o.value!="number"||typeof o.unit!="string"||typeof t.margin!="object"||t.margin===null)return!1;const l=t.margin;for(const i of["top","right","bottom","left"]){const a=l[i];if(typeof a!="object"||a===null)return!1;const c=a;if(typeof c.value!="number"||typeof c.unit!="string")return!1}return!0}function Jo(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)}function zn(e){if(typeof e!="object"||e===null)throw new Error("Schema must be an object");const t=e;if(!Zo(t.paper))throw new Error("Invalid paper definition");if(!qo(t.grid))throw new Error("Invalid grid definition");if(!Array.isArray(t.blocks))throw new Error("blocks must be an array");if(!t.blocks.every(Ko))throw new Error("Invalid block definition in blocks array");if(t.metaData!==void 0){if(typeof t.metaData!="object"||t.metaData===null)throw new Error("metaData must be an object if provided");const n=t.metaData;for(const s in n)if(!Jo(n[s]))throw new Error(`Invalid value in metaData.${s}`)}return t}function $t(e){try{const t=JSON.parse(e);return zn(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function Tt(e,t=!1){try{return t?JSON.stringify(e,null,2):JSON.stringify(e)}catch(n){throw new Error(`Failed to serialize schema: ${n instanceof Error?n.message:"Unknown error"}`)}}function Wn(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?!0:typeof e=="object"&&!Array.isArray(e)?Object.values(e).every(Wn):!1}function Yn(e){if(typeof e!="object"||e===null)throw new Error("Values must be an object");if(Array.isArray(e))throw new Error("Values must be an object, not an array");const t=e;for(const n in t)if(!Wn(t[n]))throw new Error(`Invalid value at key "${n}"`);return t}function Ct(e){try{const t=JSON.parse(e);return Yn(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function Rt(e,t=!1){try{return t?JSON.stringify(e,null,2):JSON.stringify(e)}catch(n){throw new Error(`Failed to serialize values: ${n instanceof Error?n.message:"Unknown error"}`)}}const Ke={all:{color:"#3b82f688",width:{value:4,unit:"px"},type:de.SOLID}},ht={size:12,backgroundColor:"#ffffff",borderColor:"#3b82f6",borderWidth:1,borderRadius:"50%"},J={base:B.INTERACTION_LAYER_BASE,select_block:B.SELECT_BLOCK,block_ghost:B.BLOCK_GHOST,hover_outline:B.HOVER_OUTLINE,edit_block:B.EDIT_BLOCK,grid_ghost:B.GRID_GHOST,grid_handles:B.GRID_HANDLES,select_border:B.BLOCK_SELECT_BORDER,block_handles:B.BLOCK_HANDLES,rubber_band:B.RUBBER_BAND};var U=(e=>(e.IDLE="idle",e.PRESSING="pressing",e.DRAGGING="dragging",e.EDITING="editing",e))(U||{}),H=(e=>(e.N="n",e.NE="ne",e.E="e",e.SE="se",e.S="s",e.SW="sw",e.W="w",e.NW="nw",e))(H||{}),oe=(e=>(e.MOVE="move",e.RESIZE="resize",e.INSERT="insert",e))(oe||{}),G=(e=>(e.SELECT="select",e.DESELECT="deselect",e.START_PRESS="startPress",e.UPDATE_DRAG="updateDrag",e.END_DRAG="endDrag",e.CANCEL_DRAG="cancelDrag",e.EDIT="edit",e.END_EDIT="endEdit",e.START_INSERT="startInsert",e.CANCEL_INSERT="cancelInsert",e.START_RESIZE="startResize",e))(G||{});const Qo="_interactionBlock_145kg_7",es="_resizeHandle_145kg_7",Hn={interactionBlock:Qo,resizeHandle:es},ts=[{id:H.NW,cursor:"nwse-resize",x:0,y:0},{id:H.N,cursor:"ns-resize",x:50,y:0},{id:H.NE,cursor:"nesw-resize",x:100,y:0},{id:H.W,cursor:"ew-resize",x:0,y:50},{id:H.E,cursor:"ew-resize",x:100,y:50},{id:H.SW,cursor:"nesw-resize",x:0,y:100},{id:H.S,cursor:"ns-resize",x:50,y:100},{id:H.SE,cursor:"nwse-resize",x:100,y:100}],Ut=u.memo(({onResizeStart:e,activeHandle:t,handleStyle:n=ht,zIndex:s=B.BLOCK_HANDLES})=>{const o=n.size,l=o/2;return r.jsx(r.Fragment,{children:ts.map(({id:i,cursor:a,x:c,y:d})=>{const f=c===50?`calc(50% - ${l}px)`:c===100?`calc(100% - ${l}px)`:`-${l}px`,x=d===50?`calc(50% - ${l}px)`:d===100?`calc(100% - ${l}px)`:`-${l}px`,b=t===i;return r.jsx("div",{className:Hn.resizeHandle,onPointerDown:v=>{v.stopPropagation(),e(v,i)},style:{position:"absolute",left:f,top:x,width:`${o}px`,height:`${o}px`,backgroundColor:b?n.borderColor:n.backgroundColor,border:`${n.borderWidth}px solid ${n.borderColor}`,borderRadius:n.borderRadius,cursor:a,zIndex:s,pointerEvents:"auto",boxSizing:"border-box",opacity:b?1:void 0,transition:"opacity 0.2s, background-color 0.2s, transform 0.2s",transform:b?"scale(1.2)":void 0},"data-testid":`resize-handle-${i}`},i)})})});Ut.displayName="ResizeHandles";const Kn=u.memo(({width:e,height:t,zIndex:n=B.BLOCK_SELECT_BORDER,borderStyle:s=Ke})=>{const o=u.useMemo(()=>new Ae(s),[s]),l={position:"absolute",inset:0,pointerEvents:"none",zIndex:n};return r.jsx("div",{style:l,children:r.jsx(De,{width:e,height:t,border:o})})}),Le=u.memo(({block:e,rect:t,showHandles:n=!1,onResizeStart:s,activeHandle:o,selectionStyle:l=Ke,handleStyle:i=ht,selectBorderZIndex:a=J.select_border,blockHandlesZIndex:c=J.block_handles})=>{const d={position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none"};return r.jsxs("div",{className:Hn.interactionBlock,style:d,"data-testid":"interaction-block","data-block-id":e.id,children:[r.jsx(Kn,{width:t.width,height:t.height,zIndex:a,borderStyle:l}),n&&s&&r.jsx(Ut,{onResizeStart:s,activeHandle:o,handleStyle:i,zIndex:c})]})});Le.displayName="InteractionBlock";const Ft=u.memo(({pluginRegistry:e,gridLength:t,getBlockRectPx:n,currentGrid:s,currentMousePx:o,pluginKind:l,defaultSize:i,isOutside:a,selectionStyle:c,ghostZIndex:d=J.block_ghost,selectBorderZIndex:f=J.select_border,blockHandlesZIndex:x=J.block_handles})=>{const b=e[l];if(!b)return null;let v;if(a&&o){const y=Ie(b,{x:0,y:0,w:i.w,h:i.h}),h=n(y);v={left:o.x-h.width/2,top:o.y-h.height/2,width:h.width,height:h.height}}else{const y=t.cols-i.w,h=t.rows-i.h,p=Math.max(0,Math.min(s.col,y)),m=Math.max(0,Math.min(s.row,h)),w=Ie(b,{x:p,y:m,w:i.w,h:i.h});v=n(w)}const E=Ie(b,{x:0,y:0,w:i.w,h:i.h});return r.jsxs("div",{"data-testid":"insert-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:[r.jsx("div",{style:{position:"absolute",left:`${v.left}px`,top:`${v.top}px`,width:`${v.width}px`,height:`${v.height}px`,opacity:a?.3:.6,filter:a?"grayscale(100%)":"none",zIndex:d},children:r.jsx(Ye,{id:E.id,plugin:b,props:E.props,value:E.initValue,onChange:()=>{},readOnly:!0,mode:ce.EDIT,blockSizePx:v,blockZIndex:d})}),r.jsx(Le,{block:E,rect:v,selectionStyle:c,selectBorderZIndex:f,blockHandlesZIndex:x})]})});Ft.displayName="InsertGhost";function zt(e,t,n,s,o){if(e.length===0)return[];if(e.length===1){const p=e[0];if(!p)return[];const m=s-p.layout.w,w=o-p.layout.h,_=Math.max(0,Math.min(p.layout.x+t,m)),D=Math.max(0,Math.min(p.layout.y+n,w));return[{blockId:p.id,x:_,y:D}]}const l=Math.min(...e.map(p=>p.layout.x)),i=Math.min(...e.map(p=>p.layout.y)),a=Math.max(...e.map(p=>p.layout.x+p.layout.w)),c=Math.max(...e.map(p=>p.layout.y+p.layout.h)),d=a-l,f=c-i,x=l+t,b=i+n,v=Math.max(0,Math.min(x,s-d)),E=Math.max(0,Math.min(b,o-f)),y=v-l,h=E-i;return e.map(p=>({blockId:p.id,x:p.layout.x+y,y:p.layout.y+h}))}const Wt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,selectedBlockIds:o,deltaCol:l,deltaRow:i,isOutside:a,currentMousePx:c,selectionStyle:d,ghostZIndex:f=J.block_ghost,selectBorderZIndex:x=J.select_border,blockHandlesZIndex:b=J.block_handles})=>{const v=o.map(y=>e.find(h=>h.id===y)).filter(Boolean),E=zt(v,l,i,n.cols,n.rows);return r.jsx("div",{"data-testid":"moving-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:o.map(y=>{const h=e.find(_=>_.id===y);if(!h)return null;const p=t[h.kind];if(!p)return null;let m;if(a&&c){const _=s(h);m={left:c.x-_.width/2,top:c.y-_.height/2,width:_.width,height:_.height}}else{const _=E.find(A=>A.blockId===h.id);if(!_)return null;const D={...h,layout:{...h.layout,x:_.x,y:_.y}};m=s(D)}const w={...h,layout:{...h.layout,x:0,y:0}};return r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${m.left}px`,top:`${m.top}px`,width:`${m.width}px`,height:`${m.height}px`,opacity:a?.3:.5,filter:a?"grayscale(100%)":"none",zIndex:f},children:r.jsx(Ye,{id:w.id,plugin:p,props:w.props,value:w.initValue,onChange:()=>{},readOnly:!0,mode:ce.EDIT,blockSizePx:m,blockZIndex:f,className:"ghost-content"})}),r.jsx(Le,{block:w,rect:m,selectionStyle:d,selectBorderZIndex:x,blockHandlesZIndex:b})]},y)})})});Wt.displayName="MovingGhost";function Yt({layout:e,handle:t,deltaCol:n,deltaRow:s,gridCols:o,gridRows:l}){const i={...e};if(t===H.E||t===H.NE||t===H.SE){const a=o-e.x;i.w=Math.max(1,Math.min(e.w+n,a))}else if(t===H.W||t===H.NW||t===H.SW){const a=e.w-1,c=n>0?Math.min(n,a):n;e.x+c>=0?(i.x=e.x+c,i.w=e.w-c):(i.x=0,i.w=e.w+e.x)}if(t===H.S||t===H.SE||t===H.SW){const a=l-e.y;i.h=Math.max(1,Math.min(e.h+s,a))}else if(t===H.N||t===H.NE||t===H.NW){const a=e.h-1,c=s>0?Math.min(s,a):s;e.y+c>=0?(i.y=e.y+c,i.h=e.h-c):(i.y=0,i.h=e.h+e.y)}return i}const Ht=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,blockId:o,handle:l,deltaCol:i,deltaRow:a,isOutside:c,selectionStyle:d,ghostZIndex:f=J.block_ghost,selectBorderZIndex:x=J.select_border,blockHandlesZIndex:b=J.block_handles})=>{const v=e.find(m=>m.id===o),E=t[(v==null?void 0:v.kind)??""];if(!v||!E)return null;const y=Yt({layout:v.layout,handle:l,deltaCol:i,deltaRow:a,gridCols:n.cols,gridRows:n.rows}),h={...v,layout:y},p=s(h);return r.jsx("div",{"data-testid":"resize-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${p.left}px`,top:`${p.top}px`,width:`${p.width}px`,height:`${p.height}px`,opacity:c?.3:.5,filter:c?"grayscale(100%)":"none",zIndex:f},children:r.jsx(Ye,{id:h.id,plugin:E,props:h.props,value:h.initValue,onChange:()=>{},readOnly:!0,mode:ce.EDIT,blockSizePx:p,blockZIndex:f,className:"resize-ghost-content"})}),r.jsx(Le,{block:h,rect:p,selectionStyle:d,selectBorderZIndex:x,blockHandlesZIndex:b})]},v.id)})});Ht.displayName="ResizeGhost";const Kt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,draggingState:s,getBlockRectPx:o,selectionStyle:l=Ke,ghostZIndex:i=J.block_ghost,selectBorderZIndex:a=J.select_border,blockHandlesZIndex:c=J.block_handles})=>{if(!s)return null;const d=s.currentGrid.col-s.startGrid.col,f=s.currentGrid.row-s.startGrid.row;switch(s.type){case oe.MOVE:return r.jsx(Wt,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,selectedBlockIds:s.blockIds,deltaCol:d,deltaRow:f,isOutside:s.isOutside??!1,currentMousePx:s.currentMousePx,selectionStyle:l,ghostZIndex:i,selectBorderZIndex:a,blockHandlesZIndex:c});case oe.RESIZE:{const x=s.blockIds[0];return!x||!s.handle?null:r.jsx(Ht,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,blockId:x,handle:s.handle,deltaCol:d,deltaRow:f,isOutside:s.isOutside??!1,selectionStyle:l,ghostZIndex:i,selectBorderZIndex:a,blockHandlesZIndex:c})}case oe.INSERT:return s.defaultSize?r.jsx(Ft,{pluginRegistry:t,gridLength:n,getBlockRectPx:o,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,pluginKind:s.pluginKind||"",defaultSize:s.defaultSize,isOutside:s.isOutside??!1,selectionStyle:l,ghostZIndex:i,selectBorderZIndex:a,blockHandlesZIndex:c}):null;default:return null}});Kt.displayName="DragLayer";const ns=({id:e,plugin:t,props:n,value:s,onChange:o,onBlur:l,blockRectPx:i,zIndex:a=B.EDIT_BLOCK,validationState:c,className:d=""},f)=>{const x=u.useRef(null);u.useImperativeHandle(f,()=>({focus:()=>{var h;(h=x.current)==null||h.focus()}}),[]);const b=Bt(i,{zIndex:a,pointerEvents:"auto"}),v={width:i.width,height:i.height},E={id:e,props:n,value:s,onChange:o,onBlur:l,readOnly:!1,mode:ce.FORM,dimensions:{widthPx:v.width,heightPx:v.height},validationState:c},y=t.Renderer;return r.jsx("div",{className:d,style:b,"data-testid":"editing-block","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(y,{ref:x,...E})})},rs=u.forwardRef(ns),Xn=u.memo(rs);function qn(e){const[t,n]=u.useState({mode:U.IDLE,selectedBlockIds:[],editingBlockId:null,...e}),s=u.useCallback(o=>{n(l=>{switch(o.type){case G.SELECT:{const i=o.blockIds;return{...l,mode:U.IDLE,selectedBlockIds:i}}case G.DESELECT:return{...l,mode:U.IDLE,selectedBlockIds:[]};case G.START_PRESS:{const i=o.selectedBlockIds||[o.blockId];return{...l,mode:U.PRESSING,dragging:{type:oe.MOVE,blockIds:i,startGrid:o.startGrid,currentGrid:o.startGrid,isOutside:!1}}}case G.UPDATE_DRAG:{if(!l.dragging)return l;const i=o.currentGrid.col!==l.dragging.startGrid.col||o.currentGrid.row!==l.dragging.startGrid.row;return l.mode===U.PRESSING?i?{...l,mode:U.DRAGGING,dragging:{...l.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:{...l,dragging:{...l.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:l.mode===U.DRAGGING?{...l,dragging:{...l.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:l}case G.END_DRAG:return{...l,mode:U.IDLE,dragging:void 0};case G.CANCEL_DRAG:return{...l,mode:U.IDLE,dragging:void 0};case G.EDIT:return{...l,mode:U.EDITING,editingBlockId:o.blockId};case G.END_EDIT:return{...l,mode:U.IDLE,editingBlockId:null};case G.START_INSERT:return{...l,mode:U.DRAGGING,dragging:{type:oe.INSERT,blockIds:[],startGrid:{col:0,row:0},currentGrid:{col:0,row:0},pluginKind:o.pluginKind,defaultSize:o.defaultSize,isOutside:!1}};case G.CANCEL_INSERT:return{...l,mode:U.IDLE,dragging:void 0};case G.START_RESIZE:return{...l,mode:U.DRAGGING,dragging:{type:oe.RESIZE,blockIds:[o.blockId],startGrid:o.startGrid,currentGrid:o.startGrid,handle:o.handle,isOutside:!1}};default:return l}})},[]);return[t,s]}const Xt=u.memo(({blocks:e,selectedBlockIds:t,isDragging:n,draggingState:s,getBlockRectPx:o,onResizeStart:l,selectionStyle:i=Ke,handleStyle:a=ht,selectBorderZIndex:c=J.select_border,blockHandlesZIndex:d=J.block_handles})=>{if(n&&(s==null?void 0:s.type)!==oe.RESIZE)return null;const x=Array.from(new Set(t));return r.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:x.map(b=>{const v=e.find(h=>h.id===b);if(!v)return null;const y=(s==null?void 0:s.type)===oe.RESIZE&&s.blockIds.includes(b)?s==null?void 0:s.handle:null;return r.jsx(Le,{block:v,rect:o(v),showHandles:!0,onResizeStart:(h,p)=>l(h,p,b),activeHandle:y,selectionStyle:i,handleStyle:a,selectBorderZIndex:c,blockHandlesZIndex:d},v.id)})})});Xt.displayName="SelectionLayer";function Zn(e,t,n,s){const o=n-t.w,l=s-t.h;return{x:Math.max(0,Math.min(e.x,o)),y:Math.max(0,Math.min(e.y,l))}}function Mt(e,t,n){const{x:s,y:o}=e;for(let l=t.length-1;l>=0;l--){const i=t[l];if(!i)continue;const a=n(i);if(s>=a.left&&s<=a.left+a.width&&o>=a.top&&o<=a.top+a.height)return i.id}return null}const qt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,getColIndex:o,getRowIndex:l,state:i,onChange:a,onBlockChange:c,scale:d=1,className:f="",selectionStyle:x,handleStyle:b,editBlockZIndex:v=B.EDIT_BLOCK,selectBorderZIndex:E=J.select_border,blockHandlesZIndex:y=J.block_handles,dragGhostZIndex:h=J.block_ghost})=>{const p=u.useRef(null),m=u.useRef(null);u.useEffect(()=>{i.mode===U.EDITING&&i.editingBlockId&&setTimeout(()=>{var j;(j=m.current)==null||j.focus()},0)},[i.mode,i.editingBlockId]),u.useEffect(()=>{const j=new Set(e.map(R=>R.id)),M=i.selectedBlockIds.filter(R=>j.has(R));M.length!==i.selectedBlockIds.length&&a({type:G.SELECT,blockIds:M,shiftKey:!1})},[e,i.selectedBlockIds,a]);const w=u.useCallback(j=>{var I;if(j.button!==0)return;const M=(I=p.current)==null?void 0:I.getBoundingClientRect();if(!M)return;const R=d??1,O={x:(j.clientX-M.left)/R,y:(j.clientY-M.top)/R},C=Mt(O,e,s);if(i.mode===U.EDITING){C!==i.editingBlockId&&(a({type:G.END_EDIT}),C||a({type:G.DESELECT}));return}const L=o(O.x),N=l(O.y);if(C){j.stopPropagation();const k=i.selectedBlockIds.includes(C);if(console.log("[InteractionLayer] PointerDown on block:",{targetId:C,shiftKey:j.shiftKey,isAlreadySelected:k,currentSelection:i.selectedBlockIds}),k&&j.shiftKey){console.log("[InteractionLayer] Shift+Click deselect:",C);const P=i.selectedBlockIds.filter(F=>F!==C);console.log("[InteractionLayer] New selection:",P),a({type:G.SELECT,blockIds:P,shiftKey:!0});return}else k?(j.currentTarget.setPointerCapture(j.pointerId),a({type:G.START_PRESS,blockId:C,startGrid:{col:L,row:N},selectedBlockIds:i.selectedBlockIds})):(j.currentTarget.setPointerCapture(j.pointerId),j.shiftKey?a({type:G.SELECT,blockIds:[...i.selectedBlockIds,C],shiftKey:!0}):(a({type:G.SELECT,blockIds:[C]}),a({type:G.START_PRESS,blockId:C,startGrid:{col:L,row:N},selectedBlockIds:[C]})))}else j.stopPropagation(),a({type:G.DESELECT})},[e,s,o,l,i.mode,i.selectedBlockIds,a,d,i.editingBlockId]),_=u.useCallback(j=>{var X;if(i.mode!==U.PRESSING&&i.mode!==U.DRAGGING||!i.dragging)return;const M=(X=p.current)==null?void 0:X.getBoundingClientRect();if(!M)return;const R=d??1,O=M.width/R,C=M.height/R,L=(j.clientX-M.left)/R,N=(j.clientY-M.top)/R,I=i.dragging.type!==oe.RESIZE&&(L<0||L>O||N<0||N>C),k=Math.max(0,Math.min(L,O)),P=Math.max(0,Math.min(N,C)),F=o(k),K=l(P);a({type:G.UPDATE_DRAG,currentGrid:{col:F,row:K},currentMousePx:{x:L,y:N},isOutside:I})},[i.mode,i.dragging,o,l,a,d]),D=u.useCallback(j=>{if(i.mode===U.DRAGGING&&i.dragging){if(i.dragging.isOutside){i.dragging.type===oe.MOVE&&(c==null||c({type:ae.DELETE,blockIds:i.dragging.blockIds}),a({type:G.DESELECT})),a({type:G.END_DRAG}),j.currentTarget.releasePointerCapture(j.pointerId);return}const M=i.dragging.currentGrid.col-i.dragging.startGrid.col,R=i.dragging.currentGrid.row-i.dragging.startGrid.row;if(i.dragging.type===oe.MOVE){if(M!==0||R!==0){const O=i.dragging.blockIds.map(N=>e.find(I=>I.id===N)).filter(Boolean);if(O.length===0){a({type:G.END_DRAG}),j.currentTarget.releasePointerCapture(j.pointerId);return}const C=zt(O,M,R,n.cols,n.rows),L=O.map(N=>{const I=C.find(k=>k.blockId===N.id);return I?{...N,layout:{...N.layout,x:I.x,y:I.y}}:N});c==null||c({type:ae.MOVE,blockIds:i.dragging.blockIds,blocks:L})}}else if(i.dragging.type===oe.INSERT){const{pluginKind:O,currentGrid:C,defaultSize:L}=i.dragging;if(O&&L){const N=t[O];if(N){const{x:I,y:k}=Zn({x:C.col,y:C.row},{w:L.w,h:L.h},n.cols,n.rows),P=Ie(N,{x:I,y:k,w:L.w,h:L.h});c==null||c({type:ae.ADD,blockIds:[P.id],blocks:[P]})}}}else if(i.dragging.type===oe.RESIZE){const O=i.dragging.blockIds[0],C=e.find(N=>N.id===O),L=i.dragging.handle;if(C&&L&&(M!==0||R!==0)){const N=Yt({layout:C.layout,handle:L,deltaCol:M,deltaRow:R,gridCols:n.cols,gridRows:n.rows});(N.x!==C.layout.x||N.y!==C.layout.y||N.w!==C.layout.w||N.h!==C.layout.h)&&(c==null||c({type:ae.RESIZE,blockIds:[C.id],blocks:[{...C,layout:N}]}))}}a({type:G.END_DRAG})}else i.mode===U.PRESSING&&i.dragging&&(i.dragging.isOutside&&i.dragging.type===oe.MOVE&&(c==null||c({type:ae.DELETE,blockIds:i.dragging.blockIds}),a({type:G.DESELECT})),a({type:G.CANCEL_DRAG}));j.currentTarget.releasePointerCapture(j.pointerId)},[i.mode,i.dragging,e,n,t,c,a]),A=u.useCallback(j=>{var L;const M=(L=p.current)==null?void 0:L.getBoundingClientRect();if(!M)return;const R=d??1,O={x:(j.clientX-M.left)/R,y:(j.clientY-M.top)/R},C=Mt(O,e,s);C&&(i.selectedBlockIds.includes(C)||a({type:G.SELECT,blockIds:[C]}),a({type:G.EDIT,blockId:C}))},[e,s,a,d,i.selectedBlockIds]),$=u.useCallback(j=>{var M;if((i.mode===U.PRESSING||i.mode===U.DRAGGING)&&i.dragging){const R=(M=p.current)==null?void 0:M.getBoundingClientRect();if(R){const O=d??1,C=(j.clientX-R.left)/O,L=(j.clientY-R.top)/O,N=R.width/O,I=R.height/O,k=Math.max(0,Math.min(C,N)),P=Math.max(0,Math.min(L,I));a({type:G.UPDATE_DRAG,currentGrid:{col:o(k),row:l(P)},currentMousePx:{x:C,y:L},isOutside:!0})}}},[i.mode,i.dragging,d,o,l,a]);return r.jsxs("div",{ref:p,className:f,style:{position:"absolute",inset:0,zIndex:B.INTERACTION_LAYER_BASE,pointerEvents:"auto",touchAction:"none"},role:"application","aria-label":"Interactive canvas layer",tabIndex:-1,onPointerDown:w,onPointerMove:_,onPointerUp:D,onPointerLeave:$,onDoubleClick:A,"data-testid":"interaction-layer",children:[i.editingBlockId&&(()=>{const j=e.find(R=>R.id===i.editingBlockId),M=j?t[j.kind]:null;return!j||!M?null:r.jsx(Xn,{ref:m,id:j.id,plugin:M,props:j.props,value:j.initValue,onChange:R=>{c==null||c({type:ae.UPDATE,blockIds:[j.id],blocks:[{...j,initValue:R}]})},onBlur:R=>{c==null||c({type:ae.UPDATE,blockIds:[j.id],blocks:[{...j,initValue:R}]})},blockRectPx:s(j),zIndex:v})})(),r.jsx(Xt,{blocks:e,selectedBlockIds:i.selectedBlockIds,isDragging:i.mode===U.DRAGGING,draggingState:i.dragging,getBlockRectPx:s,onResizeStart:(j,M,R)=>{var N;const O=(N=p.current)==null?void 0:N.getBoundingClientRect();if(!O)return;i.mode===U.EDITING&&a({type:G.END_EDIT}),j.currentTarget.setPointerCapture(j.pointerId);const C=d??1,L={x:(j.clientX-O.left)/C,y:(j.clientY-O.top)/C};a({type:G.START_RESIZE,blockId:R,handle:M,startGrid:{col:o(L.x),row:l(L.y)}})},selectionStyle:x,handleStyle:b,selectBorderZIndex:E,blockHandlesZIndex:y}),r.jsx(Kt,{blocks:e,pluginRegistry:t,gridLength:n,draggingState:i.dragging,getBlockRectPx:s,selectionStyle:x,ghostZIndex:h,selectBorderZIndex:E,blockHandlesZIndex:y})]})});qt.displayName="InteractionLayer";function mt(e,t,n=W){const s=u.useMemo(()=>Y.fromDim(e.size.width),[e.size.width]),o=u.useMemo(()=>Y.fromDim(e.size.height),[e.size.height]),l=u.useMemo(()=>Y.fromDim(e.margin.top),[e.margin.top]),i=u.useMemo(()=>Y.fromDim(e.margin.bottom),[e.margin.bottom]),a=u.useMemo(()=>Y.fromDim(e.margin.left),[e.margin.left]),c=u.useMemo(()=>Y.fromDim(e.margin.right),[e.margin.right]),d=u.useMemo(()=>s-a-c,[s,a,c]),f=u.useMemo(()=>o-l-i,[o,l,i]),x=u.useMemo(()=>ot(t.cols,d),[t.cols,d]),b=u.useMemo(()=>ot(t.rows,f),[t.rows,f]),v=u.useMemo(()=>V.fromMm(s,n),[s,n]),E=u.useMemo(()=>V.fromMm(o,n),[o,n]),y=u.useMemo(()=>V.fromMm(l,n),[l,n]),h=u.useMemo(()=>V.fromMm(i,n),[i,n]),p=u.useMemo(()=>V.fromMm(a,n),[a,n]),m=u.useMemo(()=>V.fromMm(c,n),[c,n]),w=u.useMemo(()=>V.fromMm(d,n),[d,n]),_=u.useMemo(()=>V.fromMm(f,n),[f,n]),D=u.useMemo(()=>st(x,n),[x,n]),A=u.useMemo(()=>st(b,n),[b,n]),$=u.useMemo(()=>{const S=[0];for(const z of D){const me=S[S.length-1]??0;S.push(me+z)}return S},[D]),j=u.useMemo(()=>{const S=[0];for(const z of A){const me=S[S.length-1]??0;S.push(me+z)}return S},[A]),{step:M,windowPx:R}=u.useMemo(()=>Nt($),[$]),{step:O,windowPx:C}=u.useMemo(()=>Nt(j),[j]),L=u.useMemo(()=>It($,M,R),[$,M,R]),N=u.useMemo(()=>It(j,O,C),[j,O,C]),I=u.useCallback(S=>L(S-p),[L,p]),k=u.useCallback(S=>N(S-y),[N,y]),P=u.useMemo(()=>({cols:$,rows:j}),[$,j]),F=u.useMemo(()=>({width:v,height:E}),[v,E]),K=u.useMemo(()=>({top:y,bottom:h,left:p,right:m}),[y,h,p,m]),X=u.useMemo(()=>({width:w,height:_}),[w,_]),g=u.useMemo(()=>({canvas:F,margin:K,content:X}),[F,K,X]),T=u.useCallback(S=>{const{x:z,y:me,w:Oe,h:q}=S.layout,ue=P.cols,ve=P.rows;if(!ue.length||!ve.length)return{left:0,top:0,width:0,height:0};const Xe=Math.min(Math.max(0,z),ue.length-1),ar=Math.min(Math.max(0,z+Oe),ue.length-1),cn=Math.min(Math.max(0,me),ve.length-1),cr=Math.min(Math.max(0,me+q),ve.length-1),ur=(ue[Xe]??0)+p,dr=(ve[cn]??0)+y,hr=(ue[ar]??0)-(ue[Xe]??0),mr=(ve[cr]??0)-(ve[cn]??0);return{left:ur,top:dr,width:hr,height:mr}},[P,p,y]);return{paperPx:g,gridPosPx:P,getColIndex:I,getRowIndex:k,getBlockRectPx:T}}const Zt=u.memo(({schema:e,values:t,pluginRegistry:n,onValueChange:s,scale:o=1,className:l})=>{const{paperPx:i,gridPosPx:a,getBlockRectPx:c}=mt(e.paper,e.grid,W),d=u.useCallback((f,x)=>{s&&s(f,x)},[s]);return r.jsxs("div",{className:l,style:{position:"relative",width:`${i.canvas.width}px`,height:`${i.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:o!==1?`scale(${o})`:void 0,transformOrigin:"top center"},children:[r.jsx(dt,{paperPx:i,gridPosPxs:a,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(He,{blocks:e.blocks,pluginRegistry:n,mode:ce.EDIT,values:t,getBlockRectPx:c,onValueChange:d,showGuides:!0,showBorder:!0})]})});Zt.displayName="NoteEdit";const Jt=u.memo(({schema:e,pluginRegistry:t,onSchemaChange:n,onSelectionChange:s,scale:o=1,className:l})=>{const[i,a]=qn(),{paperPx:c,gridPosPx:d,getBlockRectPx:f,getColIndex:x,getRowIndex:b}=mt(e.paper,e.grid,W),v=u.useCallback(_=>{if(n)switch(_.type){case ae.MOVE:case ae.RESIZE:{if(!_.blocks)return;const D=e.blocks.map(A=>{var j;return((j=_.blocks)==null?void 0:j.find(M=>M.id===A.id))||A});n({...e,blocks:D});break}case ae.ADD:{if(!_.blocks)return;n({...e,blocks:[...e.blocks,..._.blocks]});break}case ae.DELETE:{const D=new Set(_.blockIds),A=e.blocks.filter($=>!D.has($.id));n({...e,blocks:A});break}case ae.UPDATE:{if(!_.blocks)return;const D=e.blocks.map(A=>{var R;const $=(R=_.blocks)==null?void 0:R.find(O=>O.id===A.id);if(!$)return A;const j=$.style?it($.style):$.style,M=$.props?it($.props):$.props;return{...A,...$,style:j,props:M}});n({...e,blocks:D});break}}},[e,n]),E=u.useCallback((_,D)=>{if(!n)return;const A=e.blocks.map($=>$.id===_?{...$,initValue:D}:$);n({...e,blocks:A})},[e,n]);u.useEffect(()=>{s&&s(i.selectedBlockIds)},[i.selectedBlockIds,s]);const y=u.useCallback((_,D,A)=>{if(!n)return;const $=D-1;if(_==="column"){const j=jt(e.grid.cols,$,A,c.content.width);n({...e,grid:{...e.grid,cols:j}})}else{const j=jt(e.grid.rows,$,A,c.content.height);n({...e,grid:{...e.grid,rows:j}})}},[e,c,n]),h=u.useCallback((_,D,A)=>{if(n)if(_==="column"){const $=[...e.grid.cols];$[D]=A,n({...e,grid:{...e.grid,cols:$}})}else{const $=[...e.grid.rows];$[D]=A,n({...e,grid:{...e.grid,rows:$}})}},[n,e]),p=u.useMemo(()=>e.blocks.reduce((_,D)=>(_[D.id]=D.initValue,_),{}),[e.blocks]),m=u.useCallback(()=>{const _=nt.get();_&&i.mode!==U.DRAGGING&&a({type:G.START_INSERT,pluginKind:_.kind,defaultSize:_.defaultSize})},[i.mode,a]),w=u.useCallback(()=>{},[]);return r.jsxs("div",{className:l,onPointerEnter:m,onPointerLeave:w,style:{position:"relative",width:`${c.canvas.width}px`,height:`${c.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:o!==1?`scale(${o})`:void 0,transformOrigin:"top center"},children:[r.jsx(dt,{paperPx:c,gridPosPxs:d,gridDimensions:{cols:e.grid.cols,rows:e.grid.rows},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:y,onDimensionChange:h,gridLineStyle:{color:"#e5e7eb",width:{value:1,unit:"px"},type:de.SOLID},borderStyle:{all:{color:"#000000",width:{value:1,unit:"px"},type:de.SOLID}}}),r.jsx(He,{blocks:e.blocks,pluginRegistry:t,mode:ce.FORM,values:p,selectedBlockIds:i.selectedBlockIds,getBlockRectPx:f,onValueChange:E,showGuides:!0,showBorder:!0}),r.jsx(qt,{blocks:e.blocks,gridLength:{cols:e.grid.cols.length,rows:e.grid.rows.length},pluginRegistry:t,getBlockRectPx:f,getColIndex:x,getRowIndex:b,state:i,onChange:a,onBlockChange:v,scale:o})]})});Jt.displayName="NoteForm";const Jn=({schema:e,values:t,pluginRegistry:n,scale:s=1,className:o,printMode:l=!1,printSettings:i},a)=>{const c=u.useRef(null),{paperPx:d,gridPosPx:f,getBlockRectPx:x}=mt(e.paper,e.grid,W);return u.useEffect(()=>{if(!i)return;const b=document.getElementById("dynamic-print-page-style");b&&b.remove();const v=document.createElement("style");v.id="dynamic-print-page-style";const{paperSize:E="A4",orientation:y="portrait",margin:h}=i,p=y==="landscape"?`${E} landscape`:`${E} portrait`;return v.textContent=`
22
+ <%s key={someKey} {...props} />`,z,q,ue,q),X[q+z]=!0)}if(q=null,A!==void 0&&(n(A),q=""+A),i(T)&&(n(T.key),q=""+T.key),"key"in T){A={};for(var ve in T)ve!=="key"&&(A[ve]=T[ve])}else A=T;return q&&a(A,typeof g=="function"?g.displayName||g.name||"Unknown":g),d(g,q,A,o(),me,Oe)}function x(g){b(g)?g._store&&(g._store.validated=1):typeof g=="object"&&g!==null&&g.$$typeof===M&&(g._payload.status==="fulfilled"?b(g._payload.value)&&g._payload.value._store&&(g._payload.value._store.validated=1):g._store&&(g._store.validated=1))}function b(g){return typeof g=="object"&&g!==null&&g.$$typeof===E}var v=u,E=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),_=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),O=Symbol.for("react.client.reference"),R=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,N=Array.isArray,I=console.createTask?console.createTask:function(){return null};v={react_stack_bottom_frame:function(g){return g()}};var k,P={},F=v.react_stack_bottom_frame.bind(v,l)(),K=I(s(l)),X={};Be.Fragment=h,Be.jsx=function(g,T,A){var z=1e4>R.recentlyCreatedOwnerStacks++;return f(g,T,A,!1,z?Error("react-stack-top-frame"):F,z?I(s(g)):K)},Be.jsxs=function(g,T,A){var z=1e4>R.recentlyCreatedOwnerStacks++;return f(g,T,A,!0,z?Error("react-stack-top-frame"):F,z?I(s(g)):K)}})()),Be}var hn;function gr(){return hn||(hn=1,process.env.NODE_ENV==="production"?qe.exports=br():qe.exports=vr()),qe.exports}var r=gr(),Re=(e=>(e.left="flex-start",e.center="center",e.right="flex-end",e))(Re||{}),Ce=(e=>(e.top="flex-start",e.center="center",e.bottom="flex-end",e))(Ce||{});const wr="_container_1mr3i_5",_r="_select_1mr3i_11",yr="_placeholderOverlay_1mr3i_44",xt={container:wr,select:_r,placeholderOverlay:yr},we=e=>{const{value:t,onChange:n,readOnly:s=!1,config:o}=e,l=e.options??(o==null?void 0:o.options)??[],i=e.placeholder??(o==null?void 0:o.placeholder)??"選択してください",a=e.width??(o==null?void 0:o.width),c=e.height??(o==null?void 0:o.height),d=u.useCallback(E=>{const y=E.target.value;if(y==="")n(void 0);else{const h=l.find(p=>String(p.value)===y);n(h?h.value:y)}},[n,l]),f=t??"",x=t!==void 0&&t!=="",b={};a!==void 0?b.width=`${a}px`:b.width="100%";const v={width:"100%",height:c?`${c}px`:void 0};return r.jsxs("div",{className:xt.container,style:b,children:[!x&&r.jsx("input",{className:xt.placeholderOverlay,style:v,readOnly:!0,placeholder:i}),r.jsx("select",{className:xt.select,style:v,value:f,onChange:d,disabled:s,children:l.map(E=>r.jsx("option",{value:String(E.value),children:E.label},String(E.value)))})]})};we.displayName="Select";const xn={justifyContent:{defaultValue:Re.left,label:"水平方向の配置",group:"配置",description:"ブロック内のコンテンツの水平方向の配置を設定します。",Component:we,config:{options:[{label:"左揃え",value:Re.left},{label:"中央揃え",value:Re.center},{label:"右揃え",value:Re.right}]}},alignItems:{defaultValue:Ce.center,label:"垂直方向の配置",group:"配置",description:"ブロック内のコンテンツの垂直方向の配置を設定します。",Component:we,config:{options:[{label:"上揃え",value:Ce.top},{label:"中央揃え",value:Ce.center},{label:"下揃え",value:Ce.bottom}]}}},Er="_container_1tnp6_5",jr="_input_1tnp6_13",Nr="_label_1tnp6_29",bt={container:Er,input:jr,label:Nr},xe=({value:e,onChange:t,readOnly:n=!1,label:s,config:o})=>{const l=s??(o==null?void 0:o.label),i=u.useCallback(a=>{t(a.target.checked)},[t]);return r.jsxs("label",{className:bt.container,children:[r.jsx("input",{type:"checkbox",className:bt.input,checked:!!e,onChange:i,disabled:n}),l&&r.jsx("span",{className:bt.label,children:l})]})};xe.displayName="Checkbox";const Ir="_container_qbvob_5",Dr="_colorButton_qbvob_13",$r="_textInputWrapper_qbvob_40",Tr="_textInputPrefix_qbvob_62",Rr="_textInput_qbvob_40",Cr="_popover_qbvob_125",Mr="_palette_qbvob_141",kr="_paletteButton_qbvob_148",Pr="_selected_qbvob_171",Ar="_transparentPaletteButton_qbvob_177",Sr="_rgbaInputs_qbvob_183",Lr="_rgbaInputGroup_qbvob_190",Or="_rgbaLabel_qbvob_205",te={container:Ir,colorButton:Dr,textInputWrapper:$r,textInputPrefix:Tr,textInput:Rr,popover:Cr,palette:Mr,paletteButton:kr,selected:Pr,transparentPaletteButton:Ar,rgbaInputs:Sr,rgbaInputGroup:Lr,rgbaLabel:Or};function yt(e){if(!e)return null;const t=e.match(/^#([0-9a-f]{6}|[0-9a-f]{8})$/i);if(t&&typeof t[1]=="string"){const s=t[1],o=Number.parseInt(s.slice(0,2),16),l=Number.parseInt(s.slice(2,4),16),i=Number.parseInt(s.slice(4,6),16),a=s.length===8?Number.parseInt(s.slice(6,8),16)/255:1;return{r:o,g:l,b:i,a}}const n=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){const s=Number.parseInt(n[1]??"",10),o=Number.parseInt(n[2]??"",10),l=Number.parseInt(n[3]??"",10),i=n[4]?Number.parseFloat(n[4]):1;return{r:s,g:o,b:l,a:i}}return null}function bn(e){const{r:t,g:n,b:s,a:o}=e;if(o===0)return;const l=t.toString(16).padStart(2,"0"),i=n.toString(16).padStart(2,"0"),a=s.toString(16).padStart(2,"0");if(o<1){const c=Math.round(o*255).toString(16).padStart(2,"0");return`#${l}${i}${a}${c}`}return`#${l}${i}${a}`}function Gr(e){const{r:t,g:n,b:s,a:o}=e;if(o!==0)return`rgba(${t}, ${n}, ${s}, ${o})`}function Br(e){return/^#([0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)}const vn=[{label:"無色",value:void 0},{label:"白",value:"#ffffff"},{label:"グレー1",value:"#efefef"},{label:"グレー2",value:"#d9d9d9"},{label:"グレー3",value:"#cccccc"},{label:"グレー4",value:"#b7b7b7"},{label:"グレー5",value:"#999999"},{label:"グレー6",value:"#666666"},{label:"グレー7",value:"#434343"},{label:"黒",value:"#000000"},{label:"薄茶",value:"#E6B8AF"},{label:"薄赤",value:"#F4CCCC"},{label:"薄橙",value:"#FCE5CD"},{label:"薄黄",value:"#FFF2CC"},{label:"薄緑",value:"#D9EAD3"},{label:"薄青緑",value:"#D0E0E3"},{label:"薄青",value:"#C9DAF8"},{label:"薄青紫",value:"#CFE2F3"},{label:"薄紫",value:"#D9D2E9"},{label:"薄赤紫",value:"#EAD1DC"},{label:"茶",value:"#DD7E6B"},{label:"赤",value:"#EA9999"},{label:"橙",value:"#F9CB9C"},{label:"黄",value:"#FFE599"},{label:"緑",value:"#B6D7A8"},{label:"青緑",value:"#A2C4C9"},{label:"青",value:"#A4C2F4"},{label:"青紫",value:"#9FC5E8"},{label:"紫",value:"#B4A7D6"},{label:"赤紫",value:"#D5A6BD"}],kt=({onColorSelect:e,selectedColor:t,readOnly:n=!1})=>r.jsx("div",{className:te.palette,children:vn.map((s,o)=>{const l=s.value===void 0,i=s.value===t,a=l?{}:{backgroundColor:s.value};return r.jsx("button",{type:"button",className:`${te.paletteButton} ${l?te.transparentPaletteButton:""} ${i?te.selected:""}`,onClick:()=>e(s.value),disabled:n,title:s.label,"aria-label":s.label,style:a},s.value??`undefined-${o}`)})});kt.displayName="ColorPalette";const Vr="_input_14n56_5",Ur={input:Vr},ie=({value:e,onChange:t,readOnly:n=!1,min:s,max:o,step:l,integer:i,placeholder:a,width:c,height:d,config:f,onBlur:x})=>{const b=s??(f==null?void 0:f.min)??1,v=o??(f==null?void 0:f.max),E=l??(f==null?void 0:f.step)??1,y=i??(f==null?void 0:f.integer)??!1,h=a??(f==null?void 0:f.placeholder),p=c??(f==null?void 0:f.width),m=d??(f==null?void 0:f.height),w=u.useCallback(D=>{const S=D.target.value;if(S===""){t(void 0);return}let $=Number.parseFloat(S);Number.isNaN($)||(y&&($=Math.round($)),b!==void 0&&$<b&&($=b),v!==void 0&&$>v&&($=v),t($))},[t,b,v,y]),_={};return p!==void 0&&(_.width=`${p}px`),m!==void 0&&(_.height=`${m}px`,_.paddingTop=0,_.paddingBottom=0),r.jsx("input",{type:"number",className:Ur.input,style:_,value:e??"",onChange:w,onBlur:x,disabled:n,min:b,max:v,step:E,placeholder:h})};ie.displayName="NumberInput";const Pt=({rgba:e,onChange:t,readOnly:n=!1})=>r.jsxs("div",{className:te.rgbaInputs,children:[r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"R"}),r.jsx(ie,{value:e.r,onChange:s=>t("r",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"G"}),r.jsx(ie,{value:e.g,onChange:s=>t("g",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"B"}),r.jsx(ie,{value:e.b,onChange:s=>t("b",s),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:te.rgbaInputGroup,children:[r.jsx("span",{className:te.rgbaLabel,children:"A"}),r.jsx(ie,{value:Math.round(e.a*100),onChange:s=>t("a",s!==void 0?s/100:void 0),min:0,max:100,step:1,integer:!0,width:48,readOnly:n})]})]});Pt.displayName="RGBAInputs";const B={GRID_CANVAS:10,MARGIN_OVERLAY:20,GRID_OVERLAY:30,BORDER_OVERLAY:40,BLOCK_LAYER_MIN:100,BLOCK_LAYER_MAX:999999,BLOCK_LAYER_STEP:100,ERROR_BORDER:11e5,ERROR_TOOLTIP:12e5,ERROR_HIGHLIGHT:13e5,SELECT_BLOCK:2e6,INTERACTION_LAYER_BASE:21e5,BLOCK_GHOST:22e5,HOVER_OUTLINE:23e5,EDIT_BLOCK:24e5,BLOCK_SELECT_BORDER:25e5,BLOCK_HANDLES:26e5,GRID_GHOST:27e5,GRID_HANDLES:28e5,RUBBER_BAND:29e5,PROPERTY_PANEL:31e5,PALETTE:32e5,TOOLTIP:33e5,DROPDOWN:34e5,CONTEXT_MENU:35e5,MODAL:36e5,DEBUG:1e7},he={BG:10,CONTENT:50,GUIDE:70,BORDER:80},At=({isOpen:e,onClose:t,rgba:n,onRgbaChange:s,onColorSelect:o,selectedColor:l,readOnly:i=!1})=>{const a=u.useRef(null);return u.useEffect(()=>{if(!e)return;const c=d=>{a.current&&!a.current.contains(d.target)&&t()};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[e,t]),e?r.jsxs("div",{className:te.popover,ref:a,style:{zIndex:B.DROPDOWN},children:[r.jsx(kt,{onColorSelect:o,selectedColor:l,readOnly:i}),r.jsx(Pt,{rgba:n,onChange:s,readOnly:i})]}):null};At.displayName="ColorPickerPopover";const ze=({value:e,onChange:t,readOnly:n=!1,showTextInput:s=!0,allowUndefined:o,placeholder:l,width:i,height:a,config:c})=>{const d=o??(c==null?void 0:c.allowUndefined)??!0,f=l??(d?"未設定":"#000000"),x=i??(c==null?void 0:c.width),b=a??(c==null?void 0:c.height),[v,E]=u.useState(!1),y=u.useRef(null),[h,p]=u.useState(()=>yt(e)??{r:0,g:0,b:0,a:1});u.useEffect(()=>{const N=yt(e);N&&p(N)},[e]);const m=u.useCallback(()=>{n||E(N=>!N)},[n]),[w,_]=u.useState(e?e.replace(/^#/,""):"");u.useEffect(()=>{_(e?e.replace(/^#/,""):"")},[e]);const D=u.useCallback(N=>{const I=N.target.value;/^[0-9A-Fa-f]*$/.test(I)&&_(I)},[]),S=u.useCallback(N=>{if(N===""&&d){t(void 0);return}/^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(N)?t(`#${N}`):_(e?e.replace(/^#/,""):"")},[t,d,e]),$=u.useCallback(N=>{S(N.target.value)},[S]),j=u.useCallback(N=>{N.key==="Enter"&&(N.preventDefault(),S(N.currentTarget.value),N.currentTarget.blur())},[S]),M=u.useCallback(N=>{t(N)},[t]),C=u.useCallback((N,I)=>{if(I===void 0)return;const k={...h,[N]:I};p(k),t(bn(k))},[h,t]),O=e??"未設定",R={};e&&(R.background=e);const L={};return x!==void 0?L.width=`${x}px`:L.width="100%",b!==void 0&&(L.height=`${b}px`),r.jsxs("div",{className:te.container,style:L,ref:y,children:[r.jsx("button",{type:"button",className:te.colorButton,onClick:m,disabled:n,title:O,"aria-label":"カラーピッカーを開く",style:R}),s&&r.jsxs("div",{className:te.textInputWrapper,children:[r.jsx("span",{className:te.textInputPrefix,children:"#"}),r.jsx("input",{type:"text",className:te.textInput,value:w,onChange:D,onKeyDown:j,onBlur:$,disabled:n,placeholder:f,maxLength:8})]}),r.jsx(At,{isOpen:v,onClose:()=>E(!1),rgba:h,onRgbaChange:C,onColorSelect:M,selectedColor:e,readOnly:n})]})};ze.displayName="ColorPicker";const Fr="_container_1n9lj_5",zr="_valueInput_1n9lj_23",Wr="_unitSelect_1n9lj_45",vt={container:Fr,valueInput:zr,unitSelect:Wr},ne=e=>{const{value:t,onChange:n,readOnly:s=!1,config:o}=e,l=e.allowedUnits??(o==null?void 0:o.allowedUnits),i=e.min??(o==null?void 0:o.min),a=e.max??(o==null?void 0:o.max),c=e.step??(o==null?void 0:o.step)??1,d=e.placeholder??(o==null?void 0:o.placeholder),f=e.width??(o==null?void 0:o.width),x=e.height??(o==null?void 0:o.height),b=(t==null?void 0:t.unit)??(l==null?void 0:l[0]),v=u.useCallback(m=>{const w=m.target.value;if(w==="")return;let _=Number.parseFloat(w);if(Number.isNaN(_))return;const D=i??1;_<D&&(_=D),a!==void 0&&_>a&&(_=a),n({value:_,unit:(t==null?void 0:t.unit)??b})},[t,n,b,i,a]),E=u.useCallback(m=>{const w=m.target.value;n({value:(t==null?void 0:t.value)??0,unit:w})},[t,n]),y=(t==null?void 0:t.value)??"",h=(t==null?void 0:t.unit)??b??"",p={};return f!==void 0?p.width=`${f}px`:p.width="100%",x!==void 0&&(p.height=`${x}px`),r.jsxs("div",{className:vt.container,style:p,children:[r.jsx("input",{type:"number",className:vt.valueInput,value:y,onChange:v,placeholder:d,min:i??1,max:a,step:c,readOnly:s,disabled:s}),r.jsx("select",{className:vt.unitSelect,value:h,onChange:E,disabled:s||!l||l.length<=1,children:l?l.map(m=>r.jsx("option",{value:m,children:m},m)):r.jsx("option",{value:h,children:h})})]})},Yr="_container_1bfk3_6",Hr="_scrollArea_1bfk3_23",Kr="_emptyState_1bfk3_31",gt={container:Yr,scrollArea:Hr,emptyState:Kr},St=({children:e,emptyMessage:t,className:n})=>r.jsx("div",{className:`${gt.container} ${n||""}`,children:e?r.jsx("div",{className:gt.scrollArea,children:e}):t&&r.jsx("div",{className:gt.emptyState,children:t})}),Xr="_root_qs6t8_3",qr="_list_qs6t8_11",Zr="_trigger_qs6t8_26",Jr="_content_qs6t8_71",lt={root:Xr,list:qr,trigger:Zr,content:Jr},at=u.createContext(void 0),Lt=({defaultValue:e,value:t,onValueChange:n,children:s,variant:o="default",className:l=""})=>{const[i,a]=u.useState(e),c=t??i,d=f=>{a(f),n==null||n(f)};return r.jsx(at.Provider,{value:{value:c,onChange:d,variant:o},children:r.jsx("div",{className:`${lt.root} ${l}`,"data-variant":o,children:s})})},Ot=({children:e,className:t="",width:n,height:s,style:o})=>{const l=u.useContext(at);if(!l)throw new Error("TabsList must be used within a Tabs component");const{variant:i}=l,a={...o};return n!==void 0&&(a.width=`${n}px`),s!==void 0&&(a.height=`${s}px`),r.jsx("div",{className:`${lt.list} ${t}`,"data-variant":i,style:a,children:e})},ye=({value:e,children:t,className:n="",disabled:s=!1,width:o,height:l,style:i})=>{const a=u.useContext(at);if(!a)throw new Error("TabsTrigger must be used within a Tabs component");const{value:c,onChange:d,variant:f}=a,x=c===e,b={...i};return o!==void 0&&(b.width=`${o}px`),l!==void 0&&(b.height=`${l}px`),r.jsx("button",{className:`${lt.trigger} ${n}`,"data-state":x?"active":"inactive","data-variant":f,onClick:()=>d(e),disabled:s,type:"button",style:b,children:t})},Ee=({value:e,children:t,className:n=""})=>{const s=u.useContext(at);if(!s)throw new Error("TabsContent must be used within a Tabs component");const{value:o}=s;return o!==e?null:r.jsx("div",{className:`${lt.content} ${n}`,children:t})},Qr="_input_9unrj_5",eo={input:Qr},Ae=({value:e,onChange:t,readOnly:n=!1,placeholder:s,maxLength:o,multiline:l,rows:i,width:a,height:c,config:d,onBlur:f})=>{const x=s??(d==null?void 0:d.placeholder),b=o??(d==null?void 0:d.maxLength),v=l??(d==null?void 0:d.multiline)??!1,E=i??(d==null?void 0:d.rows)??3,y=u.useCallback(m=>{const w=m.target.value;t(w)},[t]),h={};a!==void 0?h.width=`${a}px`:h.width="100%",c!==void 0&&(h.height=`${c}px`);const p={className:eo.input,style:h,value:e??"",onChange:y,disabled:n,placeholder:x,maxLength:b};return v?r.jsx("textarea",{...p,rows:E}):r.jsx("input",{...p,type:"text",onBlur:f})};Ae.displayName="TextInput";const to=["mm","cm","fr","inch","pt","px","%"],no=["mm","cm","pt","inch","px"],ro=["mm","cm","inch"],oo=["mm","cm","fr","inch","pt","px"],gn=["px","pt","mm"],wn=["px","pt","mm"],Te=["mm","pt","px","%"],Et=["mm","cm","inch","pt","px","%"],_n={isIndividual:{defaultValue:!1,label:"個別に設定",group:"余白",Component:xe,description:"上下左右の余白を個別に設定します"},all:{defaultValue:{value:10,unit:"px"},label:"全方向",group:"余白",Component:ne,config:{allowedUnits:Te,min:0},condition:e=>!e.isIndividual},top:{defaultValue:{value:10,unit:"px"},label:"上",group:"余白",Component:ne,config:{allowedUnits:Te,min:0},condition:e=>e.isIndividual===!0},right:{defaultValue:{value:10,unit:"px"},label:"右",group:"余白",Component:ne,config:{allowedUnits:Te,min:0},condition:e=>e.isIndividual===!0},bottom:{defaultValue:{value:10,unit:"px"},label:"下",group:"余白",Component:ne,config:{allowedUnits:Te,min:0},condition:e=>e.isIndividual===!0},left:{defaultValue:{value:10,unit:"px"},label:"左",group:"余白",Component:ne,config:{allowedUnits:Te,min:0},condition:e=>e.isIndividual===!0}},so={...xn,..._n},yn=[{label:"ゴシック体",value:"sans-serif"},{label:"明朝体",value:"serif"},{label:"等幅",value:"monospace"},{label:"Arial",value:"Arial, sans-serif"},{label:"Times New Roman",value:"'Times New Roman', serif"}],io={fontSize:{defaultValue:{value:14,unit:"pt"},label:"フォントサイズ",group:"フォント",description:"テキストのフォントサイズを設定します",Component:ne,config:{allowedUnits:wn,min:1,step:1}},fontFamily:{defaultValue:"sans-serif",label:"フォント",group:"フォント",Component:we,config:{placeholder:"フォントを選択",options:yn}},color:{defaultValue:void 0,label:"文字色",group:"フォント",Component:ze,config:{allowUndefined:!0}},fontWeight:{defaultValue:!1,label:"太字",group:"フォント",description:"テキストを太字にします",Component:xe},italic:{defaultValue:!1,label:"斜体",group:"フォント",description:"テキストを斜体にします",Component:xe},underline:{defaultValue:!1,label:"下線",group:"フォント",description:"テキストに下線を引きます",Component:xe},lineThrough:{defaultValue:!1,label:"取り消し線",group:"フォント",description:"テキストに取り消し線を引きます",Component:xe},lineHeight:{defaultValue:1.2,label:"行の高さ",group:"フォント",description:"行の高さを設定します(1.0〜3.0)",Component:ie,config:{min:1,max:3,step:.1}}};function lo(e){return e.reduce((t,n)=>(t[n.kind]=n,t),{})}var je=(e=>(e.Contain="contain",e.Cover="cover",e.Fill="fill",e.None="none",e.ScaleDown="scale-down",e))(je||{});const ao={objectFit:{defaultValue:je.Contain,label:"表示方法",group:"画像",description:"画像のサイズが枠と合わない場合の表示方法を設定します",Component:we,config:{options:[{label:"全体を表示",value:je.Contain},{label:"枠を埋める/切り抜き",value:je.Cover},{label:"引き伸ばす/縮小する",value:je.Fill},{label:"元のサイズ",value:je.None},{label:"縮小のみ",value:je.ScaleDown}]}},alt:{defaultValue:"",label:"代替テキスト",group:"画像",description:"画像が表示できない場合に表示されるテキスト",Component:Ae,config:{placeholder:"画像の説明"}}};var Me=(e=>(e.Normal="normal",e.BreakWord="break-word",e.BreakAll="break-all",e))(Me||{}),ke=(e=>(e.Normal="normal",e.NoWrap="nowrap",e.Pre="pre",e.PreWrap="pre-wrap",e.PreLine="pre-line",e))(ke||{});const co={multiline:{defaultValue:!1,label:"複数行モード",group:"設定",Component:xe,config:{label:"有効にする"}},wordWrap:{defaultValue:Me.Normal,label:"単語の折り返し",group:"設定",Component:we,config:{options:[{label:"通常",value:Me.Normal},{label:"単語で改行",value:Me.BreakWord},{label:"強制改行",value:Me.BreakAll}]},condition:e=>e.multiline===!0},whiteSpace:{defaultValue:ke.Normal,label:"空白文字の扱い",group:"設定",Component:we,config:{options:[{label:"通常",value:ke.Normal},{label:"折り返しなし",value:ke.NoWrap},{label:"そのまま表示",value:ke.Pre}]},condition:e=>e.multiline===!0}},uo={placeholder:{defaultValue:void 0,label:"プレースホルダー",group:"設定",description:"入力欄に表示するプレースホルダーテキストを設定します",Component:Ae,config:{placeholder:"例: テキストを入力してください"}}},ho={width:{defaultValue:void 0,label:"幅",group:"サイズ",description:"要素の幅を設定します",Component:ne,config:{min:0,allowedUnits:Et,placeholder:"auto"}},height:{defaultValue:void 0,label:"高さ",group:"サイズ",description:"要素の高さを設定します",Component:ne,config:{min:0,allowedUnits:Et,placeholder:"auto"}}},En=e=>{const t={};return Object.entries(e.properties).forEach(([n,s])=>{s!==!1&&typeof s=="object"&&s!==null&&"defaultValue"in s&&(t[n]=s.defaultValue)}),t};function jn(e){const t=Date.now(),n=Math.random().toString(36).slice(2);return`${e}_${t}_${n}`}function Ie(e,t,n){const s=En(e);return{id:jn(e.kind),kind:e.kind,layout:{x:t.x,y:t.y,w:t.w,h:t.h},style:{},behavior:{},props:{...s,...n}}}const mo={required:{defaultValue:!1,label:"必須項目",group:"バリデーション",description:"この項目を必須入力にします",Component:xe,config:{label:"必須にする"}},minLength:{defaultValue:void 0,label:"最小文字数",group:"バリデーション",description:"入力可能な最小文字数を設定します",Component:ie,config:{min:0,integer:!0,placeholder:"制限なし"}},maxLength:{defaultValue:void 0,label:"最大文字数",group:"バリデーション",description:"入力可能な最大文字数を設定します",Component:ie,config:{min:0,integer:!0,placeholder:"制限なし"}},pattern:{defaultValue:void 0,label:"入力パターン (正規表現)",group:"バリデーション",description:"入力値を検証する正規表現パターンを設定します",Component:Ae,config:{placeholder:"例: ^[0-9]+$"},disableInMultiSelection:!0}};var ae=(e=>(e.ADD="add",e.UPDATE="update",e.DELETE="delete",e.MOVE="move",e.RESIZE="resize",e.DUPLICATE="duplicate",e.PASTE="paste",e))(ae||{});const Nn={cols:Array.from({length:12}).map(()=>({value:1,unit:"fr"})),rows:Array.from({length:16}).map(()=>({value:1,unit:"fr"}))};var de=(e=>(e.SOLID="solid",e.DASHED="dashed",e.DOTTED="dotted",e))(de||{});const W=96;function se(e,t){if(e<=0){const n=t??"Value";throw new Error(`${n} must be positive (> 0): got ${e}`)}}function Ne(e,t){if(e<0){const n=t??"Value";throw new Error(`${n} must be non-negative (>= 0): got ${e}`)}}function In(e,t,n,s){if(e<t||e>n){const o=s??"Value";throw new Error(`${o} must be between ${t} and ${n}: got ${e}`)}}function ct(e,t){if(!Number.isInteger(e)){const n=t??"Value";throw new Error(`${n} must be an integer: got ${e}`)}}function fo(e,t){if(!Number.isFinite(e)){const n=t??"Value";throw new Error(`${n} must be a finite number: got ${e}`)}}const po=25.4,xo=2.54,bo=72,V={_assertDpi(e){se(e,"DPI"),ct(e,"DPI")},fromMm(e,t=W){return V._assertDpi(t),Ne(e,"Millimeter value"),e*t/po},fromCm(e,t=W){return V._assertDpi(t),Ne(e,"Centimeter value"),e*t/xo},fromInch(e,t=W){return V._assertDpi(t),Ne(e,"Inch value"),e*t},fromPt(e,t=W){return V._assertDpi(t),Ne(e,"Point value"),e*t/bo},fromPx(e,t=W){return V._assertDpi(t),Ne(e,"Pixel value"),e*t/W},fromDim(e,t=W,n){switch(V._assertDpi(t),Ne(e.value,"Dimension value"),e.unit){case"mm":return V.fromMm(e.value,t);case"cm":return V.fromCm(e.value,t);case"inch":return V.fromInch(e.value,t);case"pt":return V.fromPt(e.value,t);case"px":return V.fromPx(e.value,t);case"%":if(n===void 0)throw new Error("Base size must be defined for percentage values.");return e.value/100*n;case"fr":throw new Error(`Cannot convert ${e.unit} to px. Use physical units only.`);default:{const s=e.unit;throw new Error(`Unsupported unit: ${s}`)}}}},Pe=e=>{if(!(e!=null&&e.width)||!(e!=null&&e.type))return;const t=e.width.value;if(t!==0){if(e.type===de.DASHED)return`${t*4} ${t*2}`;if(e.type===de.DOTTED)return`${t*1} ${t*2}`}};class Se{constructor(t){this.style=t}get top(){return this.style.top?{...this.style.all,...this.style.top}:this.style.all}get right(){return this.style.right?{...this.style.all,...this.style.right}:this.style.all}get bottom(){return this.style.bottom?{...this.style.all,...this.style.bottom}:this.style.all}get left(){return this.style.left?{...this.style.all,...this.style.left}:this.style.all}get hasAnyBorder(){return!!(this.top||this.right||this.bottom||this.left)}getTopSVGProps(t,n=W){const s=this.top;return s?{x1:0,y1:0,x2:t,y2:0,stroke:s.color,strokeWidth:V.fromDim(s.width,n),strokeDasharray:Pe(s),vectorEffect:"non-scaling-stroke","data-edge":"top"}:null}getRightSVGProps(t,n,s=W){const o=this.right;return o?{x1:t,y1:0,x2:t,y2:n,stroke:o.color,strokeWidth:V.fromDim(o.width,s),strokeDasharray:Pe(o),vectorEffect:"non-scaling-stroke","data-edge":"right"}:null}getBottomSVGProps(t,n,s=W){const o=this.bottom;return o?{x1:0,y1:n,x2:t,y2:n,stroke:o.color,strokeWidth:V.fromDim(o.width,s),strokeDasharray:Pe(o),vectorEffect:"non-scaling-stroke","data-edge":"bottom"}:null}getLeftSVGProps(t,n=W){const s=this.left;return s?{x1:0,y1:0,x2:0,y2:t,stroke:s.color,strokeWidth:V.fromDim(s.width,n),strokeDasharray:Pe(s),vectorEffect:"non-scaling-stroke","data-edge":"left"}:null}}var ce=(e=>(e.FORM="Form",e.EDIT="Edit",e.VIEW="View",e))(ce||{}),pe=(e=>(e.A4="A4",e.B5="B5",e.A3="A3",e.LETTER="Letter",e.LEGAL="Legal",e.CUSTOM="Custom",e))(pe||{});const Gt={A4:{preset:"A4",width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}},A3:{preset:"A3",width:{value:297,unit:"mm"},height:{value:420,unit:"mm"}},B5:{preset:"B5",width:{value:182,unit:"mm"},height:{value:257,unit:"mm"}},Letter:{preset:"Letter",width:{value:8.5,unit:"inch"},height:{value:11,unit:"inch"}},Legal:{preset:"Legal",width:{value:8.5,unit:"inch"},height:{value:14,unit:"inch"}},Custom:{preset:"Custom",width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}}},Dn={top:{value:10,unit:"mm"},right:{value:10,unit:"mm"},bottom:{value:10,unit:"mm"},left:{value:10,unit:"mm"}},$n={size:Gt.A4,margin:Dn},vo={paper:$n,grid:Nn,blocks:[]};var Tn=(e=>(e.ERROR="error",e.WARNING="warning",e.INFO="info",e))(Tn||{});const De=u.memo(({width:e,height:t,border:n,dpi:s=W,className:o=""})=>n.hasAnyBorder?r.jsxs("svg",{width:e,height:t,xmlns:"http://www.w3.org/2000/svg",className:o,style:{overflow:"visible"},children:[r.jsx("title",{children:"border SVG"}),n.top&&r.jsx("line",{...n.getTopSVGProps(e,s)}),n.right&&r.jsx("line",{...n.getRightSVGProps(e,t,s)}),n.bottom&&r.jsx("line",{...n.getBottomSVGProps(e,t,s)}),n.left&&r.jsx("line",{...n.getLeftSVGProps(t,s)})]}):null);De.displayName="BorderRenderer";function Rn(e){const t=B.BLOCK_LAYER_MIN+e*B.BLOCK_LAYER_STEP;return t>=B.BLOCK_LAYER_MAX?B.BLOCK_LAYER_MAX:t}function We(e,t){const n=Math.min(Math.max(0,t),B.BLOCK_LAYER_STEP-1);return e+n}function go(){return Math.floor((B.BLOCK_LAYER_MAX-B.BLOCK_LAYER_MIN)/B.BLOCK_LAYER_STEP)}const Cn=u.memo(({blockSizePx:e,borderStyle:t,blockZIndex:n,subZIndex:s=he.BORDER,visible:o=!0,dpi:l=W,className:i=""})=>{const a=u.useMemo(()=>{if(t)return new Se(t)},[t]);if(!o||!a||!a.hasAnyBorder)return null;const c=We(n,s),d={position:"absolute",left:0,top:0,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:i,style:d,"data-testid":"block-border",children:r.jsx(De,{width:e.width,height:e.height,border:a,dpi:l})})}),Mn=u.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=he.BG,backgroundColor:s="transparent",className:o=""})=>{const l=We(t,n),i={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:s,pointerEvents:"none",zIndex:l};return r.jsx("div",{className:o,style:i,role:"presentation","aria-label":"Block background","data-testid":"block-canvas"})}),kn={color:"#cccccc",width:{value:1,unit:"pt"},type:de.SOLID},ut={all:kn},Pn=u.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=he.GUIDE,borderStyle:s=ut,visible:o=!0,dpi:l=W,className:i=""})=>{const a=u.useMemo(()=>{if(s)return new Se(s)},[s]);if(!o||!a||!a.hasAnyBorder)return null;const c=We(t,n),d={position:"absolute",left:0,top:0,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:i,style:d,"data-testid":"block-base-border",children:r.jsx(De,{width:e.width,height:e.height,border:a,dpi:l})})}),wo=({id:e,plugin:t,props:n,value:s,onChange:o,onBlur:l,readOnly:i,mode:a,blockSizePx:c,blockZIndex:d,subZIndex:f=he.CONTENT,validationState:x,className:b=""},v)=>{const E=u.useRef(null);u.useImperativeHandle(v,()=>({focus:()=>{var w;return(w=E.current)==null?void 0:w.focus()}}),[]);const y=We(d,f),h={position:"absolute",inset:0,width:`${c.width}px`,height:`${c.height}px`,zIndex:y,pointerEvents:"auto"},p={id:e,props:n,value:s,onChange:o??(()=>{}),onBlur:l,readOnly:i,mode:a,dimensions:{widthPx:c.width,heightPx:c.height},validationState:x},m=t.Renderer;return r.jsx("div",{className:b,style:h,"data-testid":"block-renderer","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(m,{ref:E,...p})})},_o=u.forwardRef(wo),Ye=u.memo(_o);function Bt(e,t){return{position:"absolute",left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,zIndex:t==null?void 0:t.zIndex,pointerEvents:(t==null?void 0:t.pointerEvents)??"auto"}}const Vt=u.memo(u.forwardRef(({block:e,plugin:t,blockRectPx:n,blockZIndex:s,mode:o,value:l,onValueChange:i,onValueBlur:a,showGuides:c=!0,showBorder:d=!0,blockSubZIndex:f={bg:he.BG,guide:he.GUIDE,content:he.CONTENT,border:he.BORDER},defaultGuideBorder:x=ut,dpi:b=W,className:v="",pointerEvents:E="none"},y)=>{var m,w,_,D;const h=Bt(n,{zIndex:s,pointerEvents:E}),p=u.useMemo(()=>({width:n.width,height:n.height}),[n.width,n.height]);return r.jsxs("div",{style:h,"data-block-id":e.id,className:v,children:[r.jsx(Mn,{blockSizePx:p,blockZIndex:s,backgroundColor:(m=e.style)==null?void 0:m.backgroundColor,subZIndex:f.bg}),c&&!((w=e.style)!=null&&w.border)&&r.jsx(Pn,{blockSizePx:p,blockZIndex:s,subZIndex:f.guide,borderStyle:x,dpi:b}),r.jsx(Ye,{id:e.id,ref:y,plugin:t,props:e.props,value:l,onChange:i,onBlur:a,readOnly:o===ce.EDIT?((_=e.behavior)==null?void 0:_.readOnly)??!1:!0,mode:o,blockSizePx:p,blockZIndex:s,subZIndex:f.content}),r.jsx(Cn,{blockSizePx:p,blockZIndex:s,borderStyle:(D=e.style)==null?void 0:D.border,subZIndex:f.border,visible:d,dpi:b})]})}));Vt.displayName="BlockContainer";const He=u.memo(({blocks:e,pluginRegistry:t,mode:n,values:s,selectedBlockIds:o=[],getBlockRectPx:l,onValueChange:i,onValueBlur:a,showGuides:c=!0,showBorder:d=!0,blockSubZIndex:f={bg:he.BG,guide:he.GUIDE,content:he.CONTENT,border:he.BORDER},defaultGuideBorder:x=ut,dpi:b=W,className:v=""})=>{const E=u.useRef(new Map),y={position:"absolute",inset:0,pointerEvents:"none"};return r.jsx("div",{className:v,style:y,"data-testid":"block-layer",children:e.map((h,p)=>{const m=t[h.kind];if(!m)return null;const w=l(h),_=o.includes(h.id);let D=Rn(p);_&&(D=B.SELECT_BLOCK);const S=s[h.id]??h.initValue;return r.jsx(Vt,{ref:$=>{$?E.current.set(h.id,$):E.current.delete(h.id)},block:h,plugin:m,blockRectPx:w,blockZIndex:D,mode:n,value:S,onValueChange:i?$=>i(h.id,$):void 0,onValueBlur:$=>a==null?void 0:a(h.id,$),showGuides:c,showBorder:d,blockSubZIndex:f,defaultGuideBorder:x,dpi:b,pointerEvents:"none"},h.id)})})});He.displayName="BlockLayer";const An=u.memo(({contentPx:e,marginLeftPx:t,marginTopPx:n,borderStyle:s,visible:o=!0,dpi:l=W,zIndex:i=B.BORDER_OVERLAY,className:a=""})=>{const c=u.useMemo(()=>{if(s)return new Se(s)},[s]);if(!o||!c||!c.hasAnyBorder)return null;const d={position:"absolute",left:`${t}px`,top:`${n}px`,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",overflow:"visible",zIndex:i};return r.jsx("div",{className:a,style:d,"data-testid":"border-overlay",children:r.jsx(De,{width:e.width,height:e.height,border:c,dpi:l})})}),Sn=u.memo(({canvasPx:e,backgroundColor:t="#ffffff",boxShadow:n="0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:s=B.GRID_CANVAS,className:o})=>{const l={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:t,boxShadow:n,pointerEvents:"none",zIndex:s};return r.jsx("div",{className:o,style:l,role:"presentation","aria-label":"Paper background","data-testid":"grid-canvas"})}),yo="_label_vgaic_1",Eo={label:yo},jo="_editor_6szgo_5",No="_input_6szgo_18",Io="_select_6szgo_38",Do="_button_6szgo_54",Ze={editor:jo,input:No,select:Io,button:Do};function Ln(e,t){const n=e.match(/^(\d+(?:\.\d+)?)([a-zA-Z%]+)$/);if(!n)throw new Error(`Invalid dimension string: ${e}`);const s=Number(n[1]),o=n[2];if(se(s,"Dimension value"),!t.includes(o))throw new Error(`Unit not allowed: ${o}`);return{value:s,unit:o}}function $o(e,t){return e.map(n=>Ln(n,t))}const To=10,Ro=25.4,Co=.352778,Mo=.264583,Y={fromCm(e){return se(e,"Centimeter value"),e*To},fromInch(e){return se(e,"Inch value"),e*Ro},fromPt(e){return se(e,"Point value"),e*Co},fromPx(e){return se(e,"Pixel value"),e*Mo},fromDim(e){switch(se(e.value,"Dimension value"),e.unit){case"mm":return e.value;case"cm":return Y.fromCm(e.value);case"inch":return Y.fromInch(e.value);case"pt":return Y.fromPt(e.value);case"px":return Y.fromPx(e.value);case"fr":case"%":throw new Error(`Cannot convert ${e.unit} to mm. Use physical units only.`);default:{const t=e.unit;throw new Error(`Unsupported unit: ${t}`)}}}};function On(e){return se(e.value,"Dimension"),`${e.value}${e.unit}`}function ko(e){return e.map(On)}const Po=["fr","px","mm","cm","pt","inch"];function Ao(e,t){if(t==="fr")return 1;switch(t){case"px":return e;case"mm":{const n=Y.fromPx(e);return Math.round(n*10)/10}case"cm":{const s=Y.fromPx(e)/10;return Math.round(s*100)/100}case"inch":{const s=Y.fromPx(e)/25.4;return Math.round(s*100)/100}case"pt":{const o=Y.fromPx(e)/25.4*72;return Math.round(o*10)/10}default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}const Gn=u.memo(({direction:e,dimension:t,currentPxSize:n,position:s,marginLeftPx:o,marginTopPx:l,onChange:i,onCancel:a})=>{const[c,d]=u.useState(t.value.toString()),[f,x]=u.useState(t.unit),b=u.useRef(null),v=u.useRef(null),E=e==="column"?{left:`${o+s}px`,top:`${l+24}px`,transform:"translateX(-50%)"}:{left:`${o+24}px`,top:`${l+s}px`,transform:"translateY(-50%)"};u.useEffect(()=>{var m,w;(m=b.current)==null||m.focus(),(w=b.current)==null||w.select()},[]),u.useEffect(()=>{const m=w=>{v.current&&!v.current.contains(w.target)&&a()};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[a]);const y=()=>{const m=Number.parseFloat(c);!Number.isNaN(m)&&m>=.1?i({unit:f,value:m}):a()},h=m=>{m.key==="Enter"?(m.preventDefault(),y()):m.key==="Escape"&&(m.preventDefault(),a())},p=m=>{const w=m.target.value;x(w);const _=Ao(n,w);d(_.toString())};return r.jsxs("div",{ref:v,className:Ze.editor,style:E,"data-testid":`grid-unit-editor-${e}`,children:[r.jsx("input",{ref:b,type:"number",className:Ze.input,value:c,onChange:m=>d(m.target.value),onKeyDown:h,min:"0.1",step:f==="fr"?"0.1":"1"}),r.jsx("select",{className:Ze.select,value:f,onChange:p,children:Po.map(m=>r.jsx("option",{value:m,children:m},m))}),r.jsx("button",{type:"button",className:Ze.button,onClick:y,title:"確定",children:"✓"})]})});Gn.displayName="GridUnitEditor";function So(e,t,n,s){if(t==="fr"){if(n!==void 0&&s!==void 0&&s>0){const o=e/s;return Math.round(n*o*100)/100}return 1}switch(t){case"px":return Math.round(e);case"mm":{const o=Y.fromPx(e);return Math.round(o*10)/10}case"cm":{const o=Y.fromPx(e);return Math.round(o/10*100)/100}case"inch":{const o=Y.fromPx(e);return Math.round(o/25.4*100)/100}case"pt":{const o=Y.fromPx(e);return Math.round(o/25.4*72*10)/10}default:{const o=t;throw new Error(`Unsupported unit: ${o}`)}}}const et=u.memo(({direction:e,index:t,dimension:n,position:s,currentPxSize:o,marginLeftPx:l,marginTopPx:i,isNearCursor:a,resizingPxSize:c,onDimensionChange:d})=>{const[f,x]=u.useState(!1);if(!a&&!f)return null;const b=e==="column"?{left:`${l+s}px`,top:`${i-20}px`,transform:"translateX(-50%)"}:{left:`${l-20}px`,top:`${i+s}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},v=()=>{x(!0)},E=m=>{d==null||d(e,t,m),x(!1)},y=()=>{x(!1)},p=c?(()=>{const m=So(c,n.unit,n.value,o);return n.unit==="fr"?`${m}fr`:`${m}${n.unit}`})():(m=>m.unit==="fr"?`${m.value}fr`:`${m.value}${m.unit}`)(n);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:Eo.label,style:b,onDoubleClick:v,"data-testid":`grid-dimension-${e}-${t}`,"aria-label":`グリッド寸法: ${p}`,children:p})," ",f&&r.jsx(Gn,{direction:e,dimension:n,currentPxSize:o,position:s,marginLeftPx:l,marginTopPx:i,onChange:E,onCancel:y})]})});et.displayName="GridDimensionLabel";function Lo(e,t,n,s){let o="";for(const l of e)o+=`M ${l} 0 L ${l} ${s} `;for(const l of t)o+=`M 0 ${l} L ${n} ${l} `;return o}const Bn=u.memo(({gridPosPx:e,contentPx:t,marginLeftPx:n,marginTopPx:s,lineStyle:o,visible:l=!0,zIndex:i=B.GRID_OVERLAY,dpi:a=W,className:c=""})=>{const d=u.useMemo(()=>Lo(e.cols.slice(1,-1),e.rows.slice(1,-1),t.width,t.height),[e,t]);if(!l||!o)return null;const f=Pe(o),x=V.fromDim(o.width,a),b={position:"absolute",left:`${n}px`,top:`${s}px`,pointerEvents:"none",zIndex:i};return r.jsx("svg",{className:c,style:b,width:t.width,height:t.height,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Grid overlay lines",children:r.jsx("path",{d,stroke:o.color,strokeWidth:x,strokeDasharray:f,fill:"none"})})}),Oo="_handle_1mgtx_1",Go="_dragging_1mgtx_19",wt={handle:Oo,dragging:Go},tt=u.memo(({direction:e,index:t,position:n,marginLeftPx:s,marginTopPx:o,onResizeStart:l,onResize:i,onResizeEnd:a})=>{const[c,d]=u.useState(!1),f=12,x=f/2,b=e==="column"?{left:`${s+n-x}px`,top:`${o-x}px`,width:`${f}px`,height:`${f}px`,cursor:"col-resize"}:{left:`${s-x}px`,top:`${o+n-x}px`,width:`${f}px`,height:`${f}px`,cursor:"row-resize"},v=u.useCallback(E=>{E.stopPropagation(),E.preventDefault();const y=e==="column"?E.clientX:E.clientY;d(!0),l==null||l(e,t);const h=m=>{const _=(e==="column"?m.clientX:m.clientY)-y;i==null||i(e,t,_)},p=m=>{const _=(e==="column"?m.clientX:m.clientY)-y;d(!1),a==null||a(e,t,_),window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",p)};window.addEventListener("pointermove",h),window.addEventListener("pointerup",p)},[e,t,l,i,a]);return r.jsx("div",{className:`${wt.handle} ${wt[e]} ${c?wt.dragging:""}`,style:b,onPointerDown:v,"data-testid":`grid-resize-handle-${e}-${t}`})});tt.displayName="GridResizeHandle";const Vn=u.memo(({paperPx:e,visible:t=!0,marginColor:n,zIndex:s=B.MARGIN_OVERLAY,className:o=""})=>{if(!t)return null;const l={position:"absolute",inset:0,pointerEvents:"none",width:`${e.canvas.width}px`,height:`${e.canvas.height}px`,zIndex:s},i={position:"absolute",backgroundColor:n||"rgba(0, 0, 0, 0.05)",pointerEvents:"none"};return r.jsxs("div",{className:o,style:l,role:"presentation","aria-label":"Printable area margin","data-testid":"margin-overlay",children:[e.margin.top>0&&r.jsx("div",{"data-testid":"margin-top",style:{...i,top:0,left:0,width:"100%",height:`${e.margin.top}px`}}),e.margin.bottom>0&&r.jsx("div",{"data-testid":"margin-bottom",style:{...i,bottom:0,left:0,width:"100%",height:`${e.margin.bottom}px`}}),e.margin.left>0&&r.jsx("div",{"data-testid":"margin-left",style:{...i,left:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.left}px`}}),e.margin.right>0&&r.jsx("div",{"data-testid":"margin-right",style:{...i,right:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.right}px`}})]})}),dt=u.memo(({paperPx:e,gridPosPxs:t,gridDimensions:n,gridLineStyle:s,borderStyle:o,backgroundColor:l="#ffffff",boxShadow:i="0 2px 8px rgba(0, 0, 0, 0.1)",marginFillColor:a="rgba(0, 0, 0, 0.05)",showGridLines:c=!0,showMargins:d=!0,showBorder:f=!0,showResizeHandles:x=!1,showDimensionLabels:b=!1,onGridResize:v,onDimensionChange:E,className:y="",zIndex:h={}})=>{const[p,m]=u.useState(null),[w,_]=u.useState(null),[D,S]=u.useState(null),$=u.useRef(null);u.useEffect(()=>{const N=k=>{if(!$.current)return;const P=$.current.getBoundingClientRect();S({x:k.clientX-P.left,y:k.clientY-P.top})},I=k=>{if(!$.current)return;const P=$.current.getBoundingClientRect();(k.clientX<P.left||k.clientX>P.right||k.clientY<P.top||k.clientY>P.bottom)&&S(null)};return window.addEventListener("mousemove",N),window.addEventListener("mouseleave",I),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseleave",I)}},[]);const j=u.useMemo(()=>{if(!D)return!1;const N=e.content.width,I=e.content.height,k=e.margin.left,P=e.margin.top;return!(D.x>=k&&D.x<=k+N&&D.y>=P&&D.y<=P+I)},[D,e]),M=u.useCallback((N,I)=>{_({direction:N,index:I})},[]),C=u.useMemo(()=>{if(!p||!w)return null;const N=w.direction==="column"?t.cols:t.rows,I=w.index,k=N[I-1],P=p.position,F=k!==void 0?P-k:0,K=p.position,X=N[I+1],g=X!==void 0?X-K:0;return{direction:w.direction,prevIndex:I-1,prevSize:F,nextIndex:I,nextSize:g}},[p,w,t]),O=u.useCallback((N,I,k)=>{const P=N==="column"?t.cols:t.rows,F=P[I];if(F===void 0)return;const K=P[I-1],X=P[I+1],g=10;let T=k;if(K!==void 0){const A=K+g-F;T=Math.max(T,A)}if(X!==void 0){const A=X-g-F;T=Math.min(T,A)}m({direction:N,position:F+T})},[t]),R=u.useCallback((N,I,k)=>{const P=N==="column"?t.cols:t.rows,F=P[I];if(F===void 0){m(null);return}const K=P[I-1],X=P[I+1],g=10;let T=k;if(K!==void 0){const A=K+g-F;T=Math.max(T,A)}if(X!==void 0){const A=X-g-F;T=Math.min(T,A)}m(null),_(null),v==null||v(N,I,T)},[t,v]),L={position:"relative",width:"100%",height:"100%"};return r.jsxs("div",{ref:$,className:y,style:L,children:[r.jsx(Sn,{canvasPx:e.canvas,backgroundColor:l,boxShadow:i,zIndex:(h==null?void 0:h.canvas)??B.GRID_CANVAS,className:y}),d&&r.jsx(Vn,{paperPx:e,visible:d,marginColor:a,zIndex:(h==null?void 0:h.margin)??B.MARGIN_OVERLAY,className:y}),c&&r.jsx(Bn,{gridPosPx:t,contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,lineStyle:s,visible:c,zIndex:(h==null?void 0:h.grid)??B.GRID_OVERLAY,dpi:W,className:y}),f&&r.jsx(An,{contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,borderStyle:o,visible:f,dpi:W,zIndex:(h==null?void 0:h.border)??B.BORDER_OVERLAY,className:y}),x&&v&&r.jsxs(r.Fragment,{children:[t.cols.map((N,I)=>{if(I===0||I===t.cols.length-1)return null;const k=`col-${I}`;return r.jsx(tt,{direction:"column",index:I,position:N,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:M,onResize:O,onResizeEnd:R},k)}),t.rows.map((N,I)=>{if(I===0||I===t.rows.length-1)return null;const k=`row-${I}`;return r.jsx(tt,{direction:"row",index:I,position:N,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:M,onResize:O,onResizeEnd:R},k)})]}),b&&n&&r.jsxs(r.Fragment,{children:[n.cols.map((N,I)=>{const k=t.cols[I],P=t.cols[I+1];if(k===void 0||P===void 0)return null;const F=(w==null?void 0:w.direction)==="column"&&(w.index===I||w.index===I+1);let K;C&&C.direction==="column"&&(C.prevIndex===I?K=C.prevSize:C.nextIndex===I&&(K=C.nextSize));const X=(k+P)/2,g=P-k,T=`col-dim-${I}`;return r.jsx(et,{direction:"column",index:I,dimension:N,position:X,currentPxSize:g,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:j||F,resizingPxSize:K,onDimensionChange:E},T)})," ",n.rows.map((N,I)=>{const k=t.rows[I],P=t.rows[I+1];if(k===void 0||P===void 0)return null;const F=(w==null?void 0:w.direction)==="row"&&(w.index===I||w.index===I+1),K=(k+P)/2,X=P-k,g=`row-dim-${I}`;return r.jsx(et,{direction:"row",index:I,dimension:N,position:K,currentPxSize:X,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:j||F,onDimensionChange:E},g)})]}),p&&r.jsx("div",{style:{position:"absolute",left:p.direction==="column"?e.margin.left+p.position:e.margin.left,top:p.direction==="row"?e.margin.top+p.position:e.margin.top,width:p.direction==="column"?"2px":e.content.width,height:p.direction==="row"?"2px":e.content.height,backgroundColor:"#3b82f6",opacity:.5,pointerEvents:"none",zIndex:B.GRID_GHOST}})]})});class Bo{constructor(){pt(this,"state",null);pt(this,"listeners",[])}start(t,n){this.state={kind:t,defaultSize:n},this.notify()}end(){this.state=null,this.notify()}get(){return this.state}subscribe(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter(n=>n!==t)}}notify(){for(const t of this.listeners)t(this.state)}}const nt=new Bo;function jt(e,t,n,s){if(t<0||t>=e.length)return e;const o=[...e],l=o[t],i=o[t+1];return!l||!i?e:l.unit==="fr"&&i.unit==="fr"?Vo(o,t,n,s):l.unit!=="fr"&&i.unit!=="fr"?Uo(o,t,n):l.unit==="fr"&&i.unit!=="fr"?mn(o,t,n,"next",s):mn(o,t,n,"current",s)}function Vo(e,t,n,s){const o=e[t],l=e[t+1];if(!o||!l)return e;const i=e.reduce((E,y)=>y.unit==="fr"?E+y.value:E,0),a=s/i,c=o.value*a,d=l.value*a,f=Math.max(10,c+n),x=Math.max(10,d-n),b=f/a,v=x/a;return e[t]={...o,value:Math.round(b*100)/100},e[t+1]={...l,value:Math.round(v*100)/100},e}function Uo(e,t,n){const s=e[t],o=e[t+1];if(!s||!o)return e;const l=V.fromDim(s),i=V.fromDim(o),a=Math.max(10,l+n),c=Math.max(10,i-n);return e[t]={...s,value:rt(a,s.unit)},e[t+1]={...o,value:rt(c,o.unit)},e}function mn(e,t,n,s,o){const l=e[t],i=e[t+1];if(!l||!i)return e;let a=0,c=0;for(const x of e)x.unit==="fr"?a+=x.value:c+=V.fromDim(x);const d=o-c,f=a>0?d/a:0;if(s==="next"){const x=V.fromDim(i),b=Math.max(10,x-n);e[t+1]={...i,value:rt(b,i.unit)};const v=b-x,E=d-v,y=l.value*f,h=Math.max(10,y+n),p=a>0?h/E*a:1;e[t]={...l,value:Math.round(p*100)/100}}else{const x=V.fromDim(l),b=Math.max(10,x+n);e[t]={...l,value:rt(b,l.unit)};const v=b-x,E=d-v,y=i.value*f,h=Math.max(10,y-n),p=a>0?h/E*a:1;e[t+1]={...i,value:Math.round(p*100)/100}}return e}function rt(e,t){switch(t){case"px":return Math.round(e);case"mm":{const n=Y.fromPx(e);return Math.round(n*10)/10}case"cm":{const n=Y.fromPx(e);return Math.round(n/10*100)/100}case"inch":{const n=Y.fromPx(e);return Math.round(n/25.4*100)/100}case"pt":{const n=Y.fromPx(e);return Math.round(n/25.4*72*10)/10}case"fr":return 1;default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}function Un(e){if(e.length===0)return[];const t=[];let n=0;for(const s of e){se(s,"Pixel value");const o=s+n,l=Math.round(o);t.push(l),n=o-l}return t}const Fo=8,zo=32,Wo=64,Yo=512,fn=(e,t,n)=>Math.min(Math.max(e,t),n);function Nt(e){const t=e.length-1,n=t>=1?e[t]??0:0,s=e.length>=1?n/t:0,o=fn(Math.ceil(Math.log2(t+1)),Fo,zo),l=fn(s*2,Wo,Yo);return{step:o,windowPx:l}}function Qe(e,t){const n=t.length-1;if(n<=0||t[0]===void 0||e<t[0]||t[n]===void 0)return-1;if(e>=t[n])return n-1;let s=1,o=n;for(;s<=o;){const l=s+o>>>1,i=t[l];if(i===void 0){o=l-1;continue}i<=e?s=l+1:o=l-1}return s-1}function It(e,t,n){const s=e.length-1;let o=0;return l=>{if(s<=0||e[0]===void 0||l<e[0]||e[s]===void 0)return-1;if(l>=e[s])return s-1;const i=e[o],a=e[o+1];if(i===void 0||a===void 0)return-1;if(i<=l&&l<a)return o;const c=i-n,d=a+n;if(l<c||l>=d)return o=Qe(l,e),o;let f=0;const x=e[o+1];if(x!==void 0&&l>=x)for(;o+1<s;){const b=e[o+1];if(b===void 0||l<b)break;if(o++,++f>t)return o=Qe(l,e),o}else for(;o>0;){const b=e[o];if(b===void 0||l>=b)break;if(o--,++f>t)return o=Qe(l,e),o}return o}}function ot(e,t){if(e.length===0)return[];se(t,"Content size");let n=0,s=0;const o=e.map(a=>{if(se(a.value,"Grid dimension value"),a.unit==="fr")return n+=a.value,null;{const c=Y.fromDim(a);return s+=c,c}});if(n===0)return In(s,0,t,"Total fixed size"),o;const l=t-s;se(l,"Content size - fixed sizes");const i=l/n;return o.map((a,c)=>{const d=e[c];if(a!=null)return a;if(!d)throw new Error(`dims[${c}] is undefined`);return d.value*i})}function st(e,t=96){se(t,"DPI"),ct(t,"DPI");const n=e.map(o=>V.fromMm(o,t));return Un(n)}function Ho(e,t,n){if(e.length===0)return[];se(n,"DPI"),ct(n,"DPI"),se(t,"Content size");const s=ot(e,t);return st(s,n)}function it(e){const t={};for(const[n,s]of Object.entries(e))if(s!=null)if(typeof s=="object"&&!Array.isArray(s)&&s!==null){const o=it(s);t[n]=o}else t[n]=s;return t}function Ko(e,t){const s={A4:{width:210,height:297},A3:{width:297,height:420},B4:{width:257,height:364},B5:{width:182,height:257},Letter:{width:215.9,height:279.4},Legal:{width:215.9,height:355.6}}[e];return t==="landscape"?{width:s.height,height:s.width}:s}function Fn(e){e!=null&&e.title&&(document.title=e.title),e!=null&&e.removeScrollbars&&(document.body.style.overflow="hidden")}function zn(e){e!=null&&e.restoreScrollbars&&(document.body.style.overflow="")}function Dt(e){Fn({title:e==null?void 0:e.title,removeScrollbars:!0});const t=()=>{var s;(s=e==null?void 0:e.onBeforePrint)==null||s.call(e)},n=()=>{var s;(s=e==null?void 0:e.onAfterPrint)==null||s.call(e),zn({restoreScrollbars:!0}),window.removeEventListener("beforeprint",t),window.removeEventListener("afterprint",n)};window.addEventListener("beforeprint",t),window.addEventListener("afterprint",n),window.print()}function Xo(e){if(typeof e!="object"||e===null)return!1;const t=e;if(typeof t.id!="string"||typeof t.kind!="string"||typeof t.layout!="object"||t.layout===null)return!1;const n=t.layout;return!(typeof n.x!="number"||typeof n.y!="number"||typeof n.w!="number"||typeof n.h!="number"||t.props!==void 0&&typeof t.props!="object")}function qo(e){return e==="fr"||e==="px"||e==="%"}function pn(e){return Array.isArray(e)?e.every(t=>{if(typeof t!="object"||t===null)return!1;const n=t;return typeof n.value=="number"&&qo(n.unit)}):!1}function Zo(e){if(typeof e!="object"||e===null)return!1;const t=e;return pn(t.cols)&&pn(t.rows)}function Jo(e){if(typeof e!="object"||e===null)return!1;const t=e;if(typeof t.size!="object"||t.size===null)return!1;const n=t.size;if(typeof n.preset!="string"||typeof n.width!="object"||n.width===null)return!1;const s=n.width;if(typeof s.value!="number"||typeof s.unit!="string"||typeof n.height!="object"||n.height===null)return!1;const o=n.height;if(typeof o.value!="number"||typeof o.unit!="string"||typeof t.margin!="object"||t.margin===null)return!1;const l=t.margin;for(const i of["top","right","bottom","left"]){const a=l[i];if(typeof a!="object"||a===null)return!1;const c=a;if(typeof c.value!="number"||typeof c.unit!="string")return!1}return!0}function Qo(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)}function Wn(e){if(typeof e!="object"||e===null)throw new Error("Schema must be an object");const t=e;if(!Jo(t.paper))throw new Error("Invalid paper definition");if(!Zo(t.grid))throw new Error("Invalid grid definition");if(!Array.isArray(t.blocks))throw new Error("blocks must be an array");if(!t.blocks.every(Xo))throw new Error("Invalid block definition in blocks array");if(t.metaData!==void 0){if(typeof t.metaData!="object"||t.metaData===null)throw new Error("metaData must be an object if provided");const n=t.metaData;for(const s in n)if(!Qo(n[s]))throw new Error(`Invalid value in metaData.${s}`)}return t}function $t(e){try{const t=JSON.parse(e);return Wn(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function Tt(e,t=!1){try{return t?JSON.stringify(e,null,2):JSON.stringify(e)}catch(n){throw new Error(`Failed to serialize schema: ${n instanceof Error?n.message:"Unknown error"}`)}}function Yn(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?!0:typeof e=="object"&&!Array.isArray(e)?Object.values(e).every(Yn):!1}function Hn(e){if(typeof e!="object"||e===null)throw new Error("Values must be an object");if(Array.isArray(e))throw new Error("Values must be an object, not an array");const t=e;for(const n in t)if(!Yn(t[n]))throw new Error(`Invalid value at key "${n}"`);return t}function Rt(e){try{const t=JSON.parse(e);return Hn(t)}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON format: ${t.message}`):t}}function Ct(e,t=!1){try{return t?JSON.stringify(e,null,2):JSON.stringify(e)}catch(n){throw new Error(`Failed to serialize values: ${n instanceof Error?n.message:"Unknown error"}`)}}const Ke={all:{color:"#3b82f688",width:{value:4,unit:"px"},type:de.SOLID}},ht={size:12,backgroundColor:"#ffffff",borderColor:"#3b82f6",borderWidth:1,borderRadius:"50%"},J={base:B.INTERACTION_LAYER_BASE,select_block:B.SELECT_BLOCK,block_ghost:B.BLOCK_GHOST,hover_outline:B.HOVER_OUTLINE,edit_block:B.EDIT_BLOCK,grid_ghost:B.GRID_GHOST,grid_handles:B.GRID_HANDLES,select_border:B.BLOCK_SELECT_BORDER,block_handles:B.BLOCK_HANDLES,rubber_band:B.RUBBER_BAND};var U=(e=>(e.IDLE="idle",e.PRESSING="pressing",e.DRAGGING="dragging",e.EDITING="editing",e))(U||{}),H=(e=>(e.N="n",e.NE="ne",e.E="e",e.SE="se",e.S="s",e.SW="sw",e.W="w",e.NW="nw",e))(H||{}),oe=(e=>(e.MOVE="move",e.RESIZE="resize",e.INSERT="insert",e))(oe||{}),G=(e=>(e.SELECT="select",e.DESELECT="deselect",e.START_PRESS="startPress",e.UPDATE_DRAG="updateDrag",e.END_DRAG="endDrag",e.CANCEL_DRAG="cancelDrag",e.EDIT="edit",e.END_EDIT="endEdit",e.START_INSERT="startInsert",e.CANCEL_INSERT="cancelInsert",e.START_RESIZE="startResize",e))(G||{});const es="_interactionBlock_145kg_7",ts="_resizeHandle_145kg_7",Kn={interactionBlock:es,resizeHandle:ts},ns=[{id:H.NW,cursor:"nwse-resize",x:0,y:0},{id:H.N,cursor:"ns-resize",x:50,y:0},{id:H.NE,cursor:"nesw-resize",x:100,y:0},{id:H.W,cursor:"ew-resize",x:0,y:50},{id:H.E,cursor:"ew-resize",x:100,y:50},{id:H.SW,cursor:"nesw-resize",x:0,y:100},{id:H.S,cursor:"ns-resize",x:50,y:100},{id:H.SE,cursor:"nwse-resize",x:100,y:100}],Ut=u.memo(({onResizeStart:e,activeHandle:t,handleStyle:n=ht,zIndex:s=B.BLOCK_HANDLES})=>{const o=n.size,l=o/2;return r.jsx(r.Fragment,{children:ns.map(({id:i,cursor:a,x:c,y:d})=>{const f=c===50?`calc(50% - ${l}px)`:c===100?`calc(100% - ${l}px)`:`-${l}px`,x=d===50?`calc(50% - ${l}px)`:d===100?`calc(100% - ${l}px)`:`-${l}px`,b=t===i;return r.jsx("div",{className:Kn.resizeHandle,onPointerDown:v=>{v.stopPropagation(),e(v,i)},style:{position:"absolute",left:f,top:x,width:`${o}px`,height:`${o}px`,backgroundColor:b?n.borderColor:n.backgroundColor,border:`${n.borderWidth}px solid ${n.borderColor}`,borderRadius:n.borderRadius,cursor:a,zIndex:s,pointerEvents:"auto",boxSizing:"border-box",opacity:b?1:void 0,transition:"opacity 0.2s, background-color 0.2s, transform 0.2s",transform:b?"scale(1.2)":void 0},"data-testid":`resize-handle-${i}`},i)})})});Ut.displayName="ResizeHandles";const Xn=u.memo(({width:e,height:t,zIndex:n=B.BLOCK_SELECT_BORDER,borderStyle:s=Ke})=>{const o=u.useMemo(()=>new Se(s),[s]),l={position:"absolute",inset:0,pointerEvents:"none",zIndex:n};return r.jsx("div",{style:l,children:r.jsx(De,{width:e,height:t,border:o})})}),Le=u.memo(({block:e,rect:t,showHandles:n=!1,onResizeStart:s,activeHandle:o,selectionStyle:l=Ke,handleStyle:i=ht,selectBorderZIndex:a=J.select_border,blockHandlesZIndex:c=J.block_handles})=>{const d={position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none"};return r.jsxs("div",{className:Kn.interactionBlock,style:d,"data-testid":"interaction-block","data-block-id":e.id,children:[r.jsx(Xn,{width:t.width,height:t.height,zIndex:a,borderStyle:l}),n&&s&&r.jsx(Ut,{onResizeStart:s,activeHandle:o,handleStyle:i,zIndex:c})]})});Le.displayName="InteractionBlock";const Ft=u.memo(({pluginRegistry:e,gridLength:t,getBlockRectPx:n,currentGrid:s,currentMousePx:o,pluginKind:l,defaultSize:i,isOutside:a,selectionStyle:c,ghostZIndex:d=J.block_ghost,selectBorderZIndex:f=J.select_border,blockHandlesZIndex:x=J.block_handles})=>{const b=e[l];if(!b)return null;let v;if(a&&o){const y=Ie(b,{x:0,y:0,w:i.w,h:i.h}),h=n(y);v={left:o.x-h.width/2,top:o.y-h.height/2,width:h.width,height:h.height}}else{const y=t.cols-i.w,h=t.rows-i.h,p=Math.max(0,Math.min(s.col,y)),m=Math.max(0,Math.min(s.row,h)),w=Ie(b,{x:p,y:m,w:i.w,h:i.h});v=n(w)}const E=Ie(b,{x:0,y:0,w:i.w,h:i.h});return r.jsxs("div",{"data-testid":"insert-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:[r.jsx("div",{style:{position:"absolute",left:`${v.left}px`,top:`${v.top}px`,width:`${v.width}px`,height:`${v.height}px`,opacity:a?.3:.6,filter:a?"grayscale(100%)":"none",zIndex:d},children:r.jsx(Ye,{id:E.id,plugin:b,props:E.props,value:E.initValue,onChange:()=>{},readOnly:!0,mode:ce.EDIT,blockSizePx:v,blockZIndex:d})}),r.jsx(Le,{block:E,rect:v,selectionStyle:c,selectBorderZIndex:f,blockHandlesZIndex:x})]})});Ft.displayName="InsertGhost";function zt(e,t,n,s,o){if(e.length===0)return[];if(e.length===1){const p=e[0];if(!p)return[];const m=s-p.layout.w,w=o-p.layout.h,_=Math.max(0,Math.min(p.layout.x+t,m)),D=Math.max(0,Math.min(p.layout.y+n,w));return[{blockId:p.id,x:_,y:D}]}const l=Math.min(...e.map(p=>p.layout.x)),i=Math.min(...e.map(p=>p.layout.y)),a=Math.max(...e.map(p=>p.layout.x+p.layout.w)),c=Math.max(...e.map(p=>p.layout.y+p.layout.h)),d=a-l,f=c-i,x=l+t,b=i+n,v=Math.max(0,Math.min(x,s-d)),E=Math.max(0,Math.min(b,o-f)),y=v-l,h=E-i;return e.map(p=>({blockId:p.id,x:p.layout.x+y,y:p.layout.y+h}))}const Wt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,selectedBlockIds:o,deltaCol:l,deltaRow:i,isOutside:a,currentMousePx:c,selectionStyle:d,ghostZIndex:f=J.block_ghost,selectBorderZIndex:x=J.select_border,blockHandlesZIndex:b=J.block_handles})=>{const v=o.map(y=>e.find(h=>h.id===y)).filter(Boolean),E=zt(v,l,i,n.cols,n.rows);return r.jsx("div",{"data-testid":"moving-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:o.map(y=>{const h=e.find(_=>_.id===y);if(!h)return null;const p=t[h.kind];if(!p)return null;let m;if(a&&c){const _=s(h);m={left:c.x-_.width/2,top:c.y-_.height/2,width:_.width,height:_.height}}else{const _=E.find(S=>S.blockId===h.id);if(!_)return null;const D={...h,layout:{...h.layout,x:_.x,y:_.y}};m=s(D)}const w={...h,layout:{...h.layout,x:0,y:0}};return r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${m.left}px`,top:`${m.top}px`,width:`${m.width}px`,height:`${m.height}px`,opacity:a?.3:.5,filter:a?"grayscale(100%)":"none",zIndex:f},children:r.jsx(Ye,{id:w.id,plugin:p,props:w.props,value:w.initValue,onChange:()=>{},readOnly:!0,mode:ce.EDIT,blockSizePx:m,blockZIndex:f,className:"ghost-content"})}),r.jsx(Le,{block:w,rect:m,selectionStyle:d,selectBorderZIndex:x,blockHandlesZIndex:b})]},y)})})});Wt.displayName="MovingGhost";function Yt({layout:e,handle:t,deltaCol:n,deltaRow:s,gridCols:o,gridRows:l}){const i={...e};if(t===H.E||t===H.NE||t===H.SE){const a=o-e.x;i.w=Math.max(1,Math.min(e.w+n,a))}else if(t===H.W||t===H.NW||t===H.SW){const a=e.w-1,c=n>0?Math.min(n,a):n;e.x+c>=0?(i.x=e.x+c,i.w=e.w-c):(i.x=0,i.w=e.w+e.x)}if(t===H.S||t===H.SE||t===H.SW){const a=l-e.y;i.h=Math.max(1,Math.min(e.h+s,a))}else if(t===H.N||t===H.NE||t===H.NW){const a=e.h-1,c=s>0?Math.min(s,a):s;e.y+c>=0?(i.y=e.y+c,i.h=e.h-c):(i.y=0,i.h=e.h+e.y)}return i}const Ht=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,blockId:o,handle:l,deltaCol:i,deltaRow:a,isOutside:c,selectionStyle:d,ghostZIndex:f=J.block_ghost,selectBorderZIndex:x=J.select_border,blockHandlesZIndex:b=J.block_handles})=>{const v=e.find(m=>m.id===o),E=t[(v==null?void 0:v.kind)??""];if(!v||!E)return null;const y=Yt({layout:v.layout,handle:l,deltaCol:i,deltaRow:a,gridCols:n.cols,gridRows:n.rows}),h={...v,layout:y},p=s(h);return r.jsx("div",{"data-testid":"resize-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${p.left}px`,top:`${p.top}px`,width:`${p.width}px`,height:`${p.height}px`,opacity:c?.3:.5,filter:c?"grayscale(100%)":"none",zIndex:f},children:r.jsx(Ye,{id:h.id,plugin:E,props:h.props,value:h.initValue,onChange:()=>{},readOnly:!0,mode:ce.EDIT,blockSizePx:p,blockZIndex:f,className:"resize-ghost-content"})}),r.jsx(Le,{block:h,rect:p,selectionStyle:d,selectBorderZIndex:x,blockHandlesZIndex:b})]},v.id)})});Ht.displayName="ResizeGhost";const Kt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,draggingState:s,getBlockRectPx:o,selectionStyle:l=Ke,ghostZIndex:i=J.block_ghost,selectBorderZIndex:a=J.select_border,blockHandlesZIndex:c=J.block_handles})=>{if(!s)return null;const d=s.currentGrid.col-s.startGrid.col,f=s.currentGrid.row-s.startGrid.row;switch(s.type){case oe.MOVE:return r.jsx(Wt,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,selectedBlockIds:s.blockIds,deltaCol:d,deltaRow:f,isOutside:s.isOutside??!1,currentMousePx:s.currentMousePx,selectionStyle:l,ghostZIndex:i,selectBorderZIndex:a,blockHandlesZIndex:c});case oe.RESIZE:{const x=s.blockIds[0];return!x||!s.handle?null:r.jsx(Ht,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,blockId:x,handle:s.handle,deltaCol:d,deltaRow:f,isOutside:s.isOutside??!1,selectionStyle:l,ghostZIndex:i,selectBorderZIndex:a,blockHandlesZIndex:c})}case oe.INSERT:return s.defaultSize?r.jsx(Ft,{pluginRegistry:t,gridLength:n,getBlockRectPx:o,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,pluginKind:s.pluginKind||"",defaultSize:s.defaultSize,isOutside:s.isOutside??!1,selectionStyle:l,ghostZIndex:i,selectBorderZIndex:a,blockHandlesZIndex:c}):null;default:return null}});Kt.displayName="DragLayer";const rs=({id:e,plugin:t,props:n,value:s,onChange:o,onBlur:l,blockRectPx:i,zIndex:a=B.EDIT_BLOCK,validationState:c,className:d=""},f)=>{const x=u.useRef(null);u.useImperativeHandle(f,()=>({focus:()=>{var h;(h=x.current)==null||h.focus()}}),[]);const b=Bt(i,{zIndex:a,pointerEvents:"auto"}),v={width:i.width,height:i.height},E={id:e,props:n,value:s,onChange:o,onBlur:l,readOnly:!1,mode:ce.FORM,dimensions:{widthPx:v.width,heightPx:v.height},validationState:c},y=t.Renderer;return r.jsx("div",{className:d,style:b,"data-testid":"editing-block","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(y,{ref:x,...E})})},os=u.forwardRef(rs),qn=u.memo(os);function Zn(e){const[t,n]=u.useState({mode:U.IDLE,selectedBlockIds:[],editingBlockId:null,...e}),s=u.useCallback(o=>{n(l=>{switch(o.type){case G.SELECT:{const i=o.blockIds;return{...l,mode:U.IDLE,selectedBlockIds:i}}case G.DESELECT:return{...l,mode:U.IDLE,selectedBlockIds:[]};case G.START_PRESS:{const i=o.selectedBlockIds||[o.blockId];return{...l,mode:U.PRESSING,dragging:{type:oe.MOVE,blockIds:i,startGrid:o.startGrid,currentGrid:o.startGrid,isOutside:!1}}}case G.UPDATE_DRAG:{if(!l.dragging)return l;const i=o.currentGrid.col!==l.dragging.startGrid.col||o.currentGrid.row!==l.dragging.startGrid.row;return l.mode===U.PRESSING?i?{...l,mode:U.DRAGGING,dragging:{...l.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:{...l,dragging:{...l.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:l.mode===U.DRAGGING?{...l,dragging:{...l.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:l}case G.END_DRAG:return{...l,mode:U.IDLE,dragging:void 0};case G.CANCEL_DRAG:return{...l,mode:U.IDLE,dragging:void 0};case G.EDIT:return{...l,mode:U.EDITING,editingBlockId:o.blockId};case G.END_EDIT:return{...l,mode:U.IDLE,editingBlockId:null};case G.START_INSERT:return{...l,mode:U.DRAGGING,dragging:{type:oe.INSERT,blockIds:[],startGrid:{col:0,row:0},currentGrid:{col:0,row:0},pluginKind:o.pluginKind,defaultSize:o.defaultSize,isOutside:!1}};case G.CANCEL_INSERT:return{...l,mode:U.IDLE,dragging:void 0};case G.START_RESIZE:return{...l,mode:U.DRAGGING,dragging:{type:oe.RESIZE,blockIds:[o.blockId],startGrid:o.startGrid,currentGrid:o.startGrid,handle:o.handle,isOutside:!1}};default:return l}})},[]);return[t,s]}const Xt=u.memo(({blocks:e,selectedBlockIds:t,isDragging:n,draggingState:s,getBlockRectPx:o,onResizeStart:l,selectionStyle:i=Ke,handleStyle:a=ht,selectBorderZIndex:c=J.select_border,blockHandlesZIndex:d=J.block_handles})=>{if(n&&(s==null?void 0:s.type)!==oe.RESIZE)return null;const x=Array.from(new Set(t));return r.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:x.map(b=>{const v=e.find(h=>h.id===b);if(!v)return null;const y=(s==null?void 0:s.type)===oe.RESIZE&&s.blockIds.includes(b)?s==null?void 0:s.handle:null;return r.jsx(Le,{block:v,rect:o(v),showHandles:!0,onResizeStart:(h,p)=>l(h,p,b),activeHandle:y,selectionStyle:i,handleStyle:a,selectBorderZIndex:c,blockHandlesZIndex:d},v.id)})})});Xt.displayName="SelectionLayer";function Jn(e,t,n,s){const o=n-t.w,l=s-t.h;return{x:Math.max(0,Math.min(e.x,o)),y:Math.max(0,Math.min(e.y,l))}}function Mt(e,t,n){const{x:s,y:o}=e;for(let l=t.length-1;l>=0;l--){const i=t[l];if(!i)continue;const a=n(i);if(s>=a.left&&s<=a.left+a.width&&o>=a.top&&o<=a.top+a.height)return i.id}return null}const qt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,getColIndex:o,getRowIndex:l,state:i,onChange:a,onBlockChange:c,scale:d=1,className:f="",selectionStyle:x,handleStyle:b,editBlockZIndex:v=B.EDIT_BLOCK,selectBorderZIndex:E=J.select_border,blockHandlesZIndex:y=J.block_handles,dragGhostZIndex:h=J.block_ghost})=>{const p=u.useRef(null),m=u.useRef(null);u.useEffect(()=>{i.mode===U.EDITING&&i.editingBlockId&&setTimeout(()=>{var j;(j=m.current)==null||j.focus()},0)},[i.mode,i.editingBlockId]),u.useEffect(()=>{const j=new Set(e.map(C=>C.id)),M=i.selectedBlockIds.filter(C=>j.has(C));M.length!==i.selectedBlockIds.length&&a({type:G.SELECT,blockIds:M,shiftKey:!1})},[e,i.selectedBlockIds,a]);const w=u.useCallback(j=>{var I;if(j.button!==0)return;const M=(I=p.current)==null?void 0:I.getBoundingClientRect();if(!M)return;const C=d??1,O={x:(j.clientX-M.left)/C,y:(j.clientY-M.top)/C},R=Mt(O,e,s);if(i.mode===U.EDITING){R!==i.editingBlockId&&(a({type:G.END_EDIT}),R||a({type:G.DESELECT}));return}const L=o(O.x),N=l(O.y);if(R){j.stopPropagation();const k=i.selectedBlockIds.includes(R);if(console.log("[InteractionLayer] PointerDown on block:",{targetId:R,shiftKey:j.shiftKey,isAlreadySelected:k,currentSelection:i.selectedBlockIds}),k&&j.shiftKey){console.log("[InteractionLayer] Shift+Click deselect:",R);const P=i.selectedBlockIds.filter(F=>F!==R);console.log("[InteractionLayer] New selection:",P),a({type:G.SELECT,blockIds:P,shiftKey:!0});return}else k?(j.currentTarget.setPointerCapture(j.pointerId),a({type:G.START_PRESS,blockId:R,startGrid:{col:L,row:N},selectedBlockIds:i.selectedBlockIds})):(j.currentTarget.setPointerCapture(j.pointerId),j.shiftKey?a({type:G.SELECT,blockIds:[...i.selectedBlockIds,R],shiftKey:!0}):(a({type:G.SELECT,blockIds:[R]}),a({type:G.START_PRESS,blockId:R,startGrid:{col:L,row:N},selectedBlockIds:[R]})))}else j.stopPropagation(),a({type:G.DESELECT})},[e,s,o,l,i.mode,i.selectedBlockIds,a,d,i.editingBlockId]),_=u.useCallback(j=>{var X;if(i.mode!==U.PRESSING&&i.mode!==U.DRAGGING||!i.dragging)return;const M=(X=p.current)==null?void 0:X.getBoundingClientRect();if(!M)return;const C=d??1,O=M.width/C,R=M.height/C,L=(j.clientX-M.left)/C,N=(j.clientY-M.top)/C,I=i.dragging.type!==oe.RESIZE&&(L<0||L>O||N<0||N>R),k=Math.max(0,Math.min(L,O)),P=Math.max(0,Math.min(N,R)),F=o(k),K=l(P);a({type:G.UPDATE_DRAG,currentGrid:{col:F,row:K},currentMousePx:{x:L,y:N},isOutside:I})},[i.mode,i.dragging,o,l,a,d]),D=u.useCallback(j=>{if(i.mode===U.DRAGGING&&i.dragging){if(i.dragging.isOutside){i.dragging.type===oe.MOVE&&(c==null||c({type:ae.DELETE,blockIds:i.dragging.blockIds}),a({type:G.DESELECT})),a({type:G.END_DRAG}),j.currentTarget.releasePointerCapture(j.pointerId);return}const M=i.dragging.currentGrid.col-i.dragging.startGrid.col,C=i.dragging.currentGrid.row-i.dragging.startGrid.row;if(i.dragging.type===oe.MOVE){if(M!==0||C!==0){const O=i.dragging.blockIds.map(N=>e.find(I=>I.id===N)).filter(Boolean);if(O.length===0){a({type:G.END_DRAG}),j.currentTarget.releasePointerCapture(j.pointerId);return}const R=zt(O,M,C,n.cols,n.rows),L=O.map(N=>{const I=R.find(k=>k.blockId===N.id);return I?{...N,layout:{...N.layout,x:I.x,y:I.y}}:N});c==null||c({type:ae.MOVE,blockIds:i.dragging.blockIds,blocks:L})}}else if(i.dragging.type===oe.INSERT){const{pluginKind:O,currentGrid:R,defaultSize:L}=i.dragging;if(O&&L){const N=t[O];if(N){const{x:I,y:k}=Jn({x:R.col,y:R.row},{w:L.w,h:L.h},n.cols,n.rows),P=Ie(N,{x:I,y:k,w:L.w,h:L.h});c==null||c({type:ae.ADD,blockIds:[P.id],blocks:[P]})}}}else if(i.dragging.type===oe.RESIZE){const O=i.dragging.blockIds[0],R=e.find(N=>N.id===O),L=i.dragging.handle;if(R&&L&&(M!==0||C!==0)){const N=Yt({layout:R.layout,handle:L,deltaCol:M,deltaRow:C,gridCols:n.cols,gridRows:n.rows});(N.x!==R.layout.x||N.y!==R.layout.y||N.w!==R.layout.w||N.h!==R.layout.h)&&(c==null||c({type:ae.RESIZE,blockIds:[R.id],blocks:[{...R,layout:N}]}))}}a({type:G.END_DRAG})}else i.mode===U.PRESSING&&i.dragging&&(i.dragging.isOutside&&i.dragging.type===oe.MOVE&&(c==null||c({type:ae.DELETE,blockIds:i.dragging.blockIds}),a({type:G.DESELECT})),a({type:G.CANCEL_DRAG}));j.currentTarget.releasePointerCapture(j.pointerId)},[i.mode,i.dragging,e,n,t,c,a]),S=u.useCallback(j=>{var L;const M=(L=p.current)==null?void 0:L.getBoundingClientRect();if(!M)return;const C=d??1,O={x:(j.clientX-M.left)/C,y:(j.clientY-M.top)/C},R=Mt(O,e,s);R&&(i.selectedBlockIds.includes(R)||a({type:G.SELECT,blockIds:[R]}),a({type:G.EDIT,blockId:R}))},[e,s,a,d,i.selectedBlockIds]),$=u.useCallback(j=>{var M;if((i.mode===U.PRESSING||i.mode===U.DRAGGING)&&i.dragging){const C=(M=p.current)==null?void 0:M.getBoundingClientRect();if(C){const O=d??1,R=(j.clientX-C.left)/O,L=(j.clientY-C.top)/O,N=C.width/O,I=C.height/O,k=Math.max(0,Math.min(R,N)),P=Math.max(0,Math.min(L,I));a({type:G.UPDATE_DRAG,currentGrid:{col:o(k),row:l(P)},currentMousePx:{x:R,y:L},isOutside:!0})}}},[i.mode,i.dragging,d,o,l,a]);return r.jsxs("div",{ref:p,className:f,style:{position:"absolute",inset:0,zIndex:B.INTERACTION_LAYER_BASE,pointerEvents:"auto",touchAction:"none"},role:"application","aria-label":"Interactive canvas layer",tabIndex:-1,onPointerDown:w,onPointerMove:_,onPointerUp:D,onPointerLeave:$,onDoubleClick:S,"data-testid":"interaction-layer",children:[i.editingBlockId&&(()=>{const j=e.find(C=>C.id===i.editingBlockId),M=j?t[j.kind]:null;return!j||!M?null:r.jsx(qn,{ref:m,id:j.id,plugin:M,props:j.props,value:j.initValue,onChange:C=>{c==null||c({type:ae.UPDATE,blockIds:[j.id],blocks:[{...j,initValue:C}]})},onBlur:C=>{c==null||c({type:ae.UPDATE,blockIds:[j.id],blocks:[{...j,initValue:C}]})},blockRectPx:s(j),zIndex:v})})(),r.jsx(Xt,{blocks:e,selectedBlockIds:i.selectedBlockIds,isDragging:i.mode===U.DRAGGING,draggingState:i.dragging,getBlockRectPx:s,onResizeStart:(j,M,C)=>{var N;const O=(N=p.current)==null?void 0:N.getBoundingClientRect();if(!O)return;i.mode===U.EDITING&&a({type:G.END_EDIT}),j.currentTarget.setPointerCapture(j.pointerId);const R=d??1,L={x:(j.clientX-O.left)/R,y:(j.clientY-O.top)/R};a({type:G.START_RESIZE,blockId:C,handle:M,startGrid:{col:o(L.x),row:l(L.y)}})},selectionStyle:x,handleStyle:b,selectBorderZIndex:E,blockHandlesZIndex:y}),r.jsx(Kt,{blocks:e,pluginRegistry:t,gridLength:n,draggingState:i.dragging,getBlockRectPx:s,selectionStyle:x,ghostZIndex:h,selectBorderZIndex:E,blockHandlesZIndex:y})]})});qt.displayName="InteractionLayer";function mt(e,t,n=W){const s=u.useMemo(()=>Y.fromDim(e.size.width),[e.size.width]),o=u.useMemo(()=>Y.fromDim(e.size.height),[e.size.height]),l=u.useMemo(()=>Y.fromDim(e.margin.top),[e.margin.top]),i=u.useMemo(()=>Y.fromDim(e.margin.bottom),[e.margin.bottom]),a=u.useMemo(()=>Y.fromDim(e.margin.left),[e.margin.left]),c=u.useMemo(()=>Y.fromDim(e.margin.right),[e.margin.right]),d=u.useMemo(()=>s-a-c,[s,a,c]),f=u.useMemo(()=>o-l-i,[o,l,i]),x=u.useMemo(()=>ot(t.cols,d),[t.cols,d]),b=u.useMemo(()=>ot(t.rows,f),[t.rows,f]),v=u.useMemo(()=>V.fromMm(s,n),[s,n]),E=u.useMemo(()=>V.fromMm(o,n),[o,n]),y=u.useMemo(()=>V.fromMm(l,n),[l,n]),h=u.useMemo(()=>V.fromMm(i,n),[i,n]),p=u.useMemo(()=>V.fromMm(a,n),[a,n]),m=u.useMemo(()=>V.fromMm(c,n),[c,n]),w=u.useMemo(()=>V.fromMm(d,n),[d,n]),_=u.useMemo(()=>V.fromMm(f,n),[f,n]),D=u.useMemo(()=>st(x,n),[x,n]),S=u.useMemo(()=>st(b,n),[b,n]),$=u.useMemo(()=>{const A=[0];for(const z of D){const me=A[A.length-1]??0;A.push(me+z)}return A},[D]),j=u.useMemo(()=>{const A=[0];for(const z of S){const me=A[A.length-1]??0;A.push(me+z)}return A},[S]),{step:M,windowPx:C}=u.useMemo(()=>Nt($),[$]),{step:O,windowPx:R}=u.useMemo(()=>Nt(j),[j]),L=u.useMemo(()=>It($,M,C),[$,M,C]),N=u.useMemo(()=>It(j,O,R),[j,O,R]),I=u.useCallback(A=>L(A-p),[L,p]),k=u.useCallback(A=>N(A-y),[N,y]),P=u.useMemo(()=>({cols:$,rows:j}),[$,j]),F=u.useMemo(()=>({width:v,height:E}),[v,E]),K=u.useMemo(()=>({top:y,bottom:h,left:p,right:m}),[y,h,p,m]),X=u.useMemo(()=>({width:w,height:_}),[w,_]),g=u.useMemo(()=>({canvas:F,margin:K,content:X}),[F,K,X]),T=u.useCallback(A=>{const{x:z,y:me,w:Oe,h:q}=A.layout,ue=P.cols,ve=P.rows;if(!ue.length||!ve.length)return{left:0,top:0,width:0,height:0};const Xe=Math.min(Math.max(0,z),ue.length-1),cr=Math.min(Math.max(0,z+Oe),ue.length-1),cn=Math.min(Math.max(0,me),ve.length-1),ur=Math.min(Math.max(0,me+q),ve.length-1),dr=(ue[Xe]??0)+p,hr=(ve[cn]??0)+y,mr=(ue[cr]??0)-(ue[Xe]??0),fr=(ve[ur]??0)-(ve[cn]??0);return{left:dr,top:hr,width:mr,height:fr}},[P,p,y]);return{paperPx:g,gridPosPx:P,getColIndex:I,getRowIndex:k,getBlockRectPx:T}}const Zt=u.memo(({schema:e,values:t,pluginRegistry:n,onValueChange:s,scale:o=1,className:l})=>{const{paperPx:i,gridPosPx:a,getBlockRectPx:c}=mt(e.paper,e.grid,W),d=u.useCallback((f,x)=>{s&&s(f,x)},[s]);return r.jsxs("div",{className:l,style:{position:"relative",width:`${i.canvas.width}px`,height:`${i.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:o!==1?`scale(${o})`:void 0,transformOrigin:"top center"},children:[r.jsx(dt,{paperPx:i,gridPosPxs:a,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(He,{blocks:e.blocks,pluginRegistry:n,mode:ce.EDIT,values:t,getBlockRectPx:c,onValueChange:d,showGuides:!0,showBorder:!0})]})});Zt.displayName="NoteEdit";const Jt=u.memo(({schema:e,pluginRegistry:t,onSchemaChange:n,onSelectionChange:s,scale:o=1,className:l})=>{const[i,a]=Zn(),{paperPx:c,gridPosPx:d,getBlockRectPx:f,getColIndex:x,getRowIndex:b}=mt(e.paper,e.grid,W),v=u.useCallback(_=>{if(n)switch(_.type){case ae.MOVE:case ae.RESIZE:{if(!_.blocks)return;const D=e.blocks.map(S=>{var j;return((j=_.blocks)==null?void 0:j.find(M=>M.id===S.id))||S});n({...e,blocks:D});break}case ae.ADD:{if(!_.blocks)return;n({...e,blocks:[...e.blocks,..._.blocks]});break}case ae.DELETE:{const D=new Set(_.blockIds),S=e.blocks.filter($=>!D.has($.id));n({...e,blocks:S});break}case ae.UPDATE:{if(!_.blocks)return;const D=e.blocks.map(S=>{var C;const $=(C=_.blocks)==null?void 0:C.find(O=>O.id===S.id);if(!$)return S;const j=$.style?it($.style):$.style,M=$.props?it($.props):$.props;return{...S,...$,style:j,props:M}});n({...e,blocks:D});break}}},[e,n]),E=u.useCallback((_,D)=>{if(!n)return;const S=e.blocks.map($=>$.id===_?{...$,initValue:D}:$);n({...e,blocks:S})},[e,n]);u.useEffect(()=>{s&&s(i.selectedBlockIds)},[i.selectedBlockIds,s]);const y=u.useCallback((_,D,S)=>{if(!n)return;const $=D-1;if(_==="column"){const j=jt(e.grid.cols,$,S,c.content.width);n({...e,grid:{...e.grid,cols:j}})}else{const j=jt(e.grid.rows,$,S,c.content.height);n({...e,grid:{...e.grid,rows:j}})}},[e,c,n]),h=u.useCallback((_,D,S)=>{if(n)if(_==="column"){const $=[...e.grid.cols];$[D]=S,n({...e,grid:{...e.grid,cols:$}})}else{const $=[...e.grid.rows];$[D]=S,n({...e,grid:{...e.grid,rows:$}})}},[n,e]),p=u.useMemo(()=>e.blocks.reduce((_,D)=>(_[D.id]=D.initValue,_),{}),[e.blocks]),m=u.useCallback(()=>{const _=nt.get();_&&i.mode!==U.DRAGGING&&a({type:G.START_INSERT,pluginKind:_.kind,defaultSize:_.defaultSize})},[i.mode,a]),w=u.useCallback(()=>{},[]);return r.jsxs("div",{className:l,onPointerEnter:m,onPointerLeave:w,style:{position:"relative",width:`${c.canvas.width}px`,height:`${c.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:o!==1?`scale(${o})`:void 0,transformOrigin:"top center"},children:[r.jsx(dt,{paperPx:c,gridPosPxs:d,gridDimensions:{cols:e.grid.cols,rows:e.grid.rows},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:y,onDimensionChange:h,gridLineStyle:{color:"#e5e7eb",width:{value:1,unit:"px"},type:de.SOLID},borderStyle:{all:{color:"#000000",width:{value:1,unit:"px"},type:de.SOLID}}}),r.jsx(He,{blocks:e.blocks,pluginRegistry:t,mode:ce.FORM,values:p,selectedBlockIds:i.selectedBlockIds,getBlockRectPx:f,onValueChange:E,showGuides:!0,showBorder:!0}),r.jsx(qt,{blocks:e.blocks,gridLength:{cols:e.grid.cols.length,rows:e.grid.rows.length},pluginRegistry:t,getBlockRectPx:f,getColIndex:x,getRowIndex:b,state:i,onChange:a,onBlockChange:v,scale:o})]})});Jt.displayName="NoteForm";const Qn=({schema:e,values:t,pluginRegistry:n,scale:s=1,className:o,printMode:l=!1,printSettings:i},a)=>{const c=u.useRef(null),{paperPx:d,gridPosPx:f,getBlockRectPx:x}=mt(e.paper,e.grid,W);return u.useEffect(()=>{if(!i)return;const b=document.getElementById("dynamic-print-page-style");b&&b.remove();const v=document.createElement("style");v.id="dynamic-print-page-style";const{paperSize:E="A4",orientation:y="portrait",margin:h}=i,p=y==="landscape"?`${E} landscape`:`${E} portrait`;return v.textContent=`
23
23
  @media print {
24
24
  @page {
25
25
  size: ${p};
@@ -29,5 +29,5 @@ React keys must be passed directly to JSX without using spread:
29
29
  ${(h==null?void 0:h.left)||"10mm"};
30
30
  }
31
31
  }
32
- `,document.head.appendChild(v),()=>{const m=document.getElementById("dynamic-print-page-style");m&&m.remove()}},[i]),u.useImperativeHandle(a,()=>({print:()=>{Dt({title:"Document"})},openPrintPreview:()=>{Dt({title:"Document"})}}),[]),r.jsxs("div",{ref:c,className:o,"data-print-mode":l,style:{position:"relative",width:`${d.canvas.width}px`,height:`${d.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:s!==1?`scale(${s})`:void 0,transformOrigin:"top center"},children:[r.jsx(dt,{paperPx:d,gridPosPxs:f,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(He,{blocks:e.blocks,pluginRegistry:n,mode:ce.VIEW,values:t,getBlockRectPx:x,showGuides:!1,showBorder:!0})]})};Jn.displayName="NoteView";const Qn=u.memo(u.forwardRef(Jn)),er=u.memo(({schema:e,values:t,mode:n,pluginRegistry:s,onSchemaChange:o,onValuesChange:l,onSelectionChange:i,scale:a=1,className:c})=>{const d=u.useCallback((f,x)=>{l&&l({...t,[f]:x})},[t,l]);return n===ce.FORM?r.jsx(Jt,{schema:e,pluginRegistry:s,onSchemaChange:o,onSelectionChange:i,scale:a,className:c}):n===ce.EDIT?r.jsx(Zt,{schema:e,values:t,pluginRegistry:s,onValueChange:d,scale:a,className:c}):r.jsx(Qn,{schema:e,values:t,pluginRegistry:s,scale:a,className:c})});er.displayName="NoteEditor";function be(e,t){if(e.length===0)return;const n=(i,a)=>{let c=i;for(const d of a){if(c==null||typeof c!="object"||Array.isArray(c))return;c=c[d]}return c},s=t.split("."),o=n(e[0],s);return e.every(i=>n(i,s)===o)?o:void 0}const os="_container_1tfjv_1",ss="_row_1tfjv_20",is="_inputWrapper_1tfjv_37",_t={container:os,row:ss,inputWrapper:is},tr=({selectedBlocks:e,onUpdateBlocks:t})=>{if(e.length===0)return null;const n=s=>{const o={};e.forEach(l=>{o[l.id]={style:{...l.style,backgroundColor:s}}}),t(o)};return r.jsx("div",{className:_t.container,children:r.jsx("div",{className:_t.row,children:r.jsx("div",{className:_t.inputWrapper,children:r.jsx(ze,{value:be(e,"style.backgroundColor"),onChange:n,allowUndefined:!0,placeholder:"無色",height:24})})})})};function _e(e,t,n){const s=t.split("."),o=(l,i)=>{const a=s[i];if(i===s.length-1){if(n==null){const{[a]:f,...x}=l;return x}return{...l,[a]:n}}const c=(l==null?void 0:l[a])||{},d=o(c,i+1);if(Object.keys(d).length===0){const{[a]:f,...x}=l;return x}return{...l,[a]:d}};return o(e,0)}const nr=({selectedBlocks:e,onUpdateBlocks:t})=>{const n=(i,a,c)=>{const d={};e.forEach(f=>{var b,v,E;let x=_e(f.style||{},`border.${i}.${a}`,c);if(a==="type"&&c==null&&(x=_e(x,`border.${i}.width`,void 0),x=_e(x,`border.${i}.color`,void 0)),a==="type"&&c!==void 0&&c!==null){const y=(b=f.style)==null?void 0:b.border,h=y==null?void 0:y[i];h!=null&&h.width||(x=_e(x,`border.${i}.width`,{value:1,unit:"px"})),h!=null&&h.color||(x=_e(x,`border.${i}.color`,"#000000"))}if(a==="color"&&c!==void 0&&c!==null){const y=(v=f.style)==null?void 0:v.border,h=y==null?void 0:y[i];h!=null&&h.type||(x=_e(x,`border.${i}.type`,de.SOLID)),h!=null&&h.width||(x=_e(x,`border.${i}.width`,{value:1,unit:"px"}))}if(a==="width"&&c!==void 0&&c!==null){const y=(E=f.style)==null?void 0:E.border,h=y==null?void 0:y[i];h!=null&&h.type||(x=_e(x,`border.${i}.type`,de.SOLID)),h!=null&&h.color||(x=_e(x,`border.${i}.color`,"#000000"))}d[f.id]={style:x}}),t(d)},s=u.useMemo(()=>{var f;if(e.length!==1)return null;const i=e[0];if(!((f=i==null?void 0:i.style)!=null&&f.border))return null;const a=i.style.border;if(!a)return null;const c=x=>x?!(x.type&&!x.width):!0;return["all","top","right","bottom","left"].every(x=>c(a[x]))?new Ae(a):null},[e]),o=i=>r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx(we,{value:be(e,`style.border.${i}.type`),onChange:a=>n(i,"type",a),placeholder:"スタイル",height:24,options:[{label:"",value:void 0},{label:"実線",value:de.SOLID},{label:"破線",value:de.DASHED},{label:"点線",value:de.DOTTED}]}),r.jsx(ne,{value:be(e,`style.border.${i}.width`),onChange:a=>n(i,"width",a),placeholder:"太さ",height:24,allowedUnits:gn,min:1}),r.jsx(ze,{value:be(e,`style.border.${i}.color`),onChange:a=>n(i,"color",a),placeholder:"色",height:24,allowUndefined:!0})]}),l={flex:1,padding:"0 2px",fontSize:"12px",minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"};return r.jsxs("div",{style:{display:"flex",flexDirection:"row",padding:"4px",alignItems:"stretch"},children:[r.jsx("div",{style:{flex:"0 0 30%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:r.jsxs("div",{style:{width:"80px",height:"80px",backgroundColor:"transparent",border:"transparent",borderRadius:"0.25rem",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[r.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",style:{position:"absolute",top:0,left:0,opacity:.3,pointerEvents:"none"},children:[r.jsx("title",{children:"枠線ガイド"}),r.jsx("line",{x1:"40",y1:"0",x2:"40",y2:"80",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"}),r.jsx("line",{x1:"0",y1:"40",x2:"80",y2:"40",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"})]}),s?r.jsx("div",{style:{position:"absolute",top:0,left:0,width:"80px",height:"80px",pointerEvents:"none"},children:r.jsx(De,{width:80,height:80,border:s})}):r.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",style:{position:"absolute",top:0,left:0,opacity:.3},children:[r.jsx("title",{children:"枠線未設定"}),r.jsx("rect",{x:"0",y:"0",width:"80",height:"80",fill:"none",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"})]})]})}),r.jsx("div",{style:{flex:"0 0 70%",minWidth:0,padding:"0 0 2px 0"},children:r.jsxs(Lt,{defaultValue:"all",variant:"segmented",children:[r.jsx("div",{style:{width:"100%"},children:r.jsxs(Ot,{style:{width:"100%",display:"flex"},children:[r.jsx(ye,{value:"all",height:24,style:l,children:"共通"}),r.jsx(ye,{value:"top",height:24,style:l,children:"上"}),r.jsx(ye,{value:"bottom",height:24,style:l,children:"下"}),r.jsx(ye,{value:"left",height:24,style:l,children:"左"}),r.jsx(ye,{value:"right",height:24,style:l,children:"右"})]})}),r.jsxs("div",{style:{marginTop:"4px"},children:[r.jsx(Ee,{value:"all",children:o("all")}),r.jsx(Ee,{value:"top",children:o("top")}),r.jsx(Ee,{value:"bottom",children:o("bottom")}),r.jsx(Ee,{value:"left",children:o("left")}),r.jsx(Ee,{value:"right",children:o("right")})]})]})})]})},ls="_container_1daw7_1",as="_grid_1daw7_19",cs="_field_1daw7_26",us="_label_1daw7_33",ds="_inputWrapper_1daw7_43",le={container:ls,grid:as,field:cs,label:us,inputWrapper:ds},rr=({selectedBlocks:e,onUpdateBlocks:t,gridSize:n})=>{if(e.length===0)return null;const s=e.length>1,o=s?Math.min(...e.map(a=>a.layout.x)):void 0,l=s?Math.min(...e.map(a=>a.layout.y)):void 0,i=(a,c)=>{if(c===void 0)return;const d={};if(s&&(a==="x"||a==="y")){const f=a==="x"?o:l;if(f===void 0)return;const x=Math.max(...e.map(p=>p.layout.x+p.layout.w)),b=Math.max(...e.map(p=>p.layout.y+p.layout.h)),v=x-(o??0),E=b-(l??0);let y=c;a==="x"&&n?y=Math.max(0,Math.min(c,n.cols-v)):a==="y"&&n?y=Math.max(0,Math.min(c,n.rows-E)):y=Math.max(0,c);const h=y-f;e.forEach(p=>{const m=p.layout[a]+h;d[p.id]={layout:{...p.layout,[a]:m}}})}else e.forEach(f=>{let x=c;if(a==="x"&&n)x=Math.max(0,Math.min(c,n.cols-f.layout.w));else if(a==="y"&&n)x=Math.max(0,Math.min(c,n.rows-f.layout.h));else if(a==="w"&&n){const b=n.cols-f.layout.x;x=Math.max(1,Math.min(c,b))}else if(a==="h"&&n){const b=n.rows-f.layout.y;x=Math.max(1,Math.min(c,b))}else a==="w"||a==="h"?x=Math.max(1,c):x=Math.max(0,c);d[f.id]={layout:{...f.layout,[a]:x}}});t(d)};return r.jsx("div",{className:le.container,children:r.jsxs("div",{className:le.grid,children:[r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"X"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:s?o:be(e,"layout.x"),onChange:a=>i("x",a),min:0,max:n?n.cols-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"Y"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:s?l:be(e,"layout.y"),onChange:a=>i("y",a),min:0,max:n?n.rows-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),!s&&r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"W"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:be(e,"layout.w"),onChange:a=>i("w",a),min:1,max:n==null?void 0:n.cols,integer:!0,height:22,placeholder:"-"})})]}),!s&&r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"H"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:be(e,"layout.h"),onChange:a=>i("h",a),min:1,max:n==null?void 0:n.rows,integer:!0,height:22,placeholder:"-"})})]})]})})},hs="_container_1h4w8_1",ms="_row_1h4w8_10",fs="_label_1h4w8_16",ps="_inputWrapper_1h4w8_25",$e={container:hs,row:ms,label:fs,inputWrapper:ps},or=({selectedBlocks:e,onUpdateBlocks:t})=>{const[n,s]=u.useState(""),o=e[0];u.useEffect(()=>{e.length===1&&o&&s(o.id)},[e,o]);const l=()=>{if(!o)return;const c=o.id,d=n.trim();if(d===c||!d){s(c);return}t({[c]:{id:d}})},i=c=>{s(c??"")},a=c=>{const d={};e.forEach(f=>{d[f.id]={behavior:{...f.behavior,readOnly:!!c}}}),t(d)};return r.jsxs("div",{className:$e.container,children:[e.length===1&&r.jsxs("div",{className:$e.row,children:[r.jsx("span",{className:$e.label,children:"ID"}),r.jsx("div",{className:$e.inputWrapper,children:r.jsx(Se,{value:n,onChange:i,onBlur:l,placeholder:"IDを入力",height:16})})]}),e.length>0&&r.jsx("div",{className:$e.row,children:r.jsx("div",{className:$e.inputWrapper,children:r.jsx(xe,{label:"読み取り専用",value:!!be(e,"behavior.readOnly"),onChange:a})})})]})},xs="_container_wa11y_1",bs="_scrollArea_wa11y_18",vs="_section_wa11y_26",gs="_sectionTitle_wa11y_35",ws="_subsection_wa11y_47",_s="_subsectionTitle_wa11y_51",ys="_fields_wa11y_59",Es="_emptyState_wa11y_69",re={container:xs,scrollArea:bs,section:vs,sectionTitle:gs,subsection:ws,subsectionTitle:_s,fields:ys,emptyState:Es},js="_field_qo0ef_1",Ns="_label_qo0ef_7",Is="_mixed_qo0ef_15",Ds="_description_qo0ef_22",Je={field:js,label:Ns,mixed:Is,description:Ds},ft=u.memo(({propertyKey:e,definition:t,selectedBlocks:n,onChange:s})=>{var f;const o=t.Component;if(!o)return null;const l=be(n,`props.${e}`),c=!n.map(x=>x.props[e]).every(x=>x===void 0)&&l===void 0&&n.length>1,d={value:c?void 0:l!==void 0?l:t.defaultValue,onChange:x=>s(e,x),readOnly:!1,config:{...t.config,placeholder:c?"複数選択中 (値が異なります)":(f=t.config)==null?void 0:f.placeholder}};return r.jsxs("div",{className:Je.field,children:[t.label&&r.jsx("div",{className:Je.label,title:t.description,children:t.label}),r.jsx(o,{...d}),c&&r.jsx("span",{className:Je.mixed,children:"(混在)"}),t.description&&r.jsx("p",{className:Je.description,children:t.description})]})});ft.displayName="PropertyField";function $s(e){return e!==!1}const Qt=u.memo(({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n,gridSize:s,className:o=""})=>{const l=e[0],i=l?t[l.kind]:void 0,a=u.useMemo(()=>{var x;if(e.length===0)return!1;const f=(x=e[0])==null?void 0:x.kind;return e.every(b=>b.kind===f)},[e]),c=u.useMemo(()=>{if(!l||!i)return{};const f={};let x;if(a)x=Object.entries(i.properties);else{const b=e.map(h=>t[h.kind]).filter(h=>h!==void 0);if(b.length===0)return{};const v=b[0];if(!v)return{};const E=new Set(Object.keys(v.properties));x=Array.from(E).filter(h=>b.every(p=>h in p.properties)).map(h=>{const p=i.properties[h];return p?[h,p]:null}).filter(h=>h!==null)}return x.forEach(([b,v])=>{if(!$s(v)||e.length>1&&v.disableInMultiSelection||v.condition&&!v.condition(l.props))return;const E=v.group||"基本";f[E]||(f[E]=[]),v.Component&&f[E].push({key:b,definition:v})}),f},[i,t,e,l,a]),d=(f,x)=>{const b={};e.forEach(v=>{b[v.id]={props:{...v.props,[f]:x}}}),n(b)};return e.length===0?r.jsx("div",{className:`${re.container} ${o}`,children:r.jsxs("div",{className:re.emptyState,children:["ブロックを選択すると",r.jsx("br",{}),"プロパティが表示されます"]})}):r.jsx("div",{className:`${re.container} ${o}`,children:r.jsxs("div",{className:re.scrollArea,children:[r.jsxs("div",{className:re.section,children:[r.jsx("div",{className:re.sectionTitle,children:"配置・サイズ"}),r.jsx(rr,{selectedBlocks:e,onUpdateBlocks:n,gridSize:s})]}),r.jsxs("div",{className:re.section,children:[r.jsx("div",{className:re.sectionTitle,children:"背景"}),r.jsx(tr,{selectedBlocks:e,onUpdateBlocks:n})]}),r.jsxs("div",{className:re.section,children:[r.jsx("div",{className:re.sectionTitle,children:"枠線"}),r.jsx(nr,{selectedBlocks:e,onUpdateBlocks:n})]}),i&&Object.keys(c).length>0&&r.jsx("div",{className:re.section,children:Object.entries(c).map(([f,x])=>r.jsxs("div",{className:re.subsection,children:[r.jsx("div",{className:re.subsectionTitle,children:f}),r.jsx("div",{className:re.fields,children:x.map(({key:b,definition:v})=>r.jsx(ft,{propertyKey:b,definition:v,selectedBlocks:e,onChange:d},b))})]},f))}),r.jsxs("div",{className:re.section,children:[r.jsx("div",{className:re.sectionTitle,children:"基本設定"}),r.jsx(or,{selectedBlocks:e,onUpdateBlocks:n})]})]})})});Qt.displayName="BlockPropertyPanel";const Ts="_panel_1h33v_1",Cs="_header_1h33v_11",Rs="_group_1h33v_18",Ms="_groupTitle_1h33v_26",ks="_groupContent_1h33v_36",Ve={panel:Ts,header:Cs,group:Rs,groupTitle:Ms,groupContent:ks};function Ps(e){return e!==!1}const Ss=({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n})=>{const s=e[0],o=s?t[s.kind]:void 0,l=u.useMemo(()=>{if(!s||!o)return{};const a={};return Object.entries(o.properties).forEach(([c,d])=>{if(!Ps(d)||e.length>1&&d.disableInMultiSelection||d.condition&&!d.condition(s.props))return;const f=d.group||"基本";a[f]||(a[f]=[]),d.Component&&a[f].push({key:c,definition:d})}),a},[o,e.length,s]),i=(a,c)=>{const d={};e.forEach(f=>{d[f.id]={props:{...f.props,[a]:c}}}),n(d)};return!s||!o||e.length===0?null:r.jsxs("div",{className:Ve.panel,children:[r.jsx("div",{className:Ve.header,children:e.length>1?`${e.length}個のブロック`:o.meta.displayName}),Object.entries(l).map(([a,c])=>r.jsxs("div",{className:Ve.group,children:[r.jsx("div",{className:Ve.groupTitle,children:a}),r.jsx("div",{className:Ve.groupContent,children:c.map(({key:d,definition:f})=>r.jsx(ft,{propertyKey:d,definition:f,selectedBlocks:e,onChange:i},d))})]},a))]})},As="_panel_1ekwd_6",Ls="_title_1ekwd_10",Os="_content_1ekwd_22",Gs="_description_1ekwd_29",Bs="_list_1ekwd_35",Vs="_item_1ekwd_44",Us="_dragging_1ekwd_61",Fs="_dragOver_1ekwd_66",zs="_dragHandle_1ekwd_71",Ws="_itemInfo_1ekwd_86",Ys="_itemId_1ekwd_93",Hs="_itemMeta_1ekwd_98",Ks="_itemKind_1ekwd_105",Xs="_itemActions_1ekwd_113",qs="_actionButton_1ekwd_118",Zs="_empty_1ekwd_154",Q={panel:As,title:Ls,content:Os,description:Gs,list:Bs,item:Vs,dragging:Us,dragOver:Fs,dragHandle:zs,itemInfo:Ws,itemId:Ys,itemMeta:Hs,itemKind:Ks,itemActions:Xs,actionButton:qs,empty:Zs},en=({blocks:e,onBlocksChange:t})=>{const[n,s]=u.useState(null),[o,l]=u.useState(null),i=[...e].reverse(),a=u.useCallback(h=>{const p=e.findIndex(_=>_.id===h);if(p===-1||p===e.length-1)return;const m=[...e],[w]=m.splice(p,1);w&&(m.push(w),t(m))},[e,t]),c=u.useCallback(h=>{const p=e.findIndex(_=>_.id===h);if(p===-1||p===0)return;const m=[...e],[w]=m.splice(p,1);w&&(m.unshift(w),t(m))},[e,t]),d=u.useCallback(h=>{const p=e.findIndex(D=>D.id===h);if(p===-1||p===e.length-1)return;const m=[...e],w=m[p],_=m[p+1];!w||!_||(m[p]=_,m[p+1]=w,t(m))},[e,t]),f=u.useCallback(h=>{const p=e.findIndex(D=>D.id===h);if(p===-1||p===0)return;const m=[...e],w=m[p],_=m[p-1];!w||!_||(m[p]=_,m[p-1]=w,t(m))},[e,t]),x=u.useCallback((h,p)=>{var w;s(p),h.dataTransfer.effectAllowed="move";const m=e.length-1-p;h.currentTarget&&h.dataTransfer.setData("text/plain",((w=e[m])==null?void 0:w.id)||"")},[e]),b=u.useCallback(()=>{s(null),l(null)},[]),v=u.useCallback((h,p)=>{h.preventDefault(),h.dataTransfer.dropEffect="move",!(n===null||n===p)&&l(p)},[n]),E=u.useCallback(()=>{l(null)},[]),y=u.useCallback((h,p)=>{if(h.preventDefault(),n===null||n===p){s(null),l(null);return}const m=e.length-1-n,w=e.length-1-p,_=[...e],[D]=_.splice(m,1);D&&(_.splice(w,0,D),t(_),s(null),l(null))},[e,n,t]);return r.jsxs("div",{className:Q.panel,children:[r.jsx("h3",{className:Q.title,children:"ブロック順序"}),r.jsxs("div",{className:Q.content,children:[r.jsx("p",{className:Q.description,children:"上が最前面、下が最背面"}),r.jsx("ul",{className:Q.list,children:i.map((h,p)=>{const m=e.length-1-p;return r.jsxs("li",{className:`${Q.item} ${n===p?Q.dragging:""} ${o===p?Q.dragOver:""}`,onDragOver:w=>v(w,p),onDragLeave:E,onDrop:w=>y(w,p),children:[r.jsx("button",{type:"button",className:Q.dragHandle,title:"ドラッグして並び替え",draggable:!0,onDragStart:w=>x(w,p),onDragEnd:b,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"ドラッグハンドル"}),r.jsx("circle",{cx:"6",cy:"4",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"4",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"6",cy:"8",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"8",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"6",cy:"12",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor"})]})}),r.jsxs("div",{className:Q.itemInfo,children:[r.jsx("div",{className:Q.itemId,children:h.id}),r.jsx("div",{className:Q.itemMeta,children:r.jsx("span",{className:Q.itemKind,children:h.kind})})]}),r.jsxs("div",{className:Q.itemActions,children:[r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>a(h.id),title:"最前面へ","aria-label":"最前面へ移動",disabled:m===e.length-1,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"最前面へ"}),r.jsx("path",{d:"M4 12v-8M8 12v-8M12 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M12 4h-8",stroke:"currentColor",strokeWidth:"2"})]})}),r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>d(h.id),title:"前面へ","aria-label":"前面へ移動",disabled:m===e.length-1,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"前面へ"}),r.jsx("path",{d:"M8 4v8",stroke:"currentColor"}),r.jsx("path",{d:"M5 7l3-3 3 3",stroke:"currentColor"})]})}),r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>f(h.id),title:"背面へ","aria-label":"背面へ移動",disabled:m===0,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"背面へ"}),r.jsx("path",{d:"M8 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M5 9l3 3 3-3",stroke:"currentColor"})]})}),r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>c(h.id),title:"最背面へ","aria-label":"最背面へ移動",disabled:m===0,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"最背面へ"}),r.jsx("path",{d:"M4 12v-8M8 12v-8M12 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M12 12h-8",stroke:"currentColor",strokeWidth:"2"})]})})]})]},h.id)})}),e.length===0&&r.jsx("div",{className:Q.empty,children:"ブロックがありません"})]})]})};en.displayName="BlockOrderPanel";const tn=({schema:e,onSchemaChange:t})=>{const n=u.useCallback(l=>{t({...e,paper:l})},[e,t]),s=u.useCallback(l=>{t({...e,grid:l})},[e,t]),o=u.useCallback(l=>{t({...e,blocks:l})},[e,t]);return r.jsxs(At,{children:[r.jsx(on,{paper:e.paper,onPaperChange:n}),r.jsx(rn,{paper:e.paper,onPaperChange:n}),r.jsx(nn,{grid:e.grid,onGridChange:s}),r.jsx(en,{blocks:e.blocks,onBlocksChange:o})]})};tn.displayName="CanvasPanel";const Js="_panel_1axyd_6",Qs="_title_1axyd_10",ei="_content_1axyd_22",ti="_field_1axyd_29",ni="_horizontal_1axyd_35",ri="_label_1axyd_41",oi="_gridSizeRow_1axyd_52",ge={panel:Js,title:Qs,content:ei,field:ti,horizontal:ni,label:ri,gridSizeRow:oi},nn=({grid:e,onGridChange:t})=>{const n=u.useCallback(o=>{if(!o||o<1||o>100)return;const l=e.cols.length,i=[];if(o>l){i.push(...e.cols);for(let a=l;a<o;a++)i.push({value:1,unit:"fr"})}else i.push(...e.cols.slice(0,o));t({...e,cols:i})},[e,t]),s=u.useCallback(o=>{if(!o||o<1||o>100)return;const l=e.rows.length,i=[];if(o>l){i.push(...e.rows);for(let a=l;a<o;a++)i.push({value:1,unit:"fr"})}else i.push(...e.rows.slice(0,o));t({...e,rows:i})},[e,t]);return r.jsxs("div",{className:ge.panel,children:[r.jsx("h3",{className:ge.title,children:"グリッドサイズ"}),r.jsx("div",{className:ge.content,children:r.jsxs("div",{className:ge.gridSizeRow,children:[r.jsxs("div",{className:`${ge.field} ${ge.horizontal}`,children:[r.jsx("span",{className:ge.label,children:"列数"}),r.jsx(ie,{value:e.cols.length,onChange:n,min:1,max:100,step:1})]}),r.jsxs("div",{className:`${ge.field} ${ge.horizontal}`,children:[r.jsx("span",{className:ge.label,children:"行数"}),r.jsx(ie,{value:e.rows.length,onChange:s,min:1,max:100,step:1})]})]})})]})};nn.displayName="GridSizePanel";const si="_panel_qlcb6_6",ii="_header_qlcb6_10",li="_title_qlcb6_20",ai="_headerActions_qlcb6_29",ci="_content_qlcb6_33",ui="_field_qlcb6_37",di="_horizontal_qlcb6_43",hi="_label_qlcb6_49",mi="_marginsGrid_qlcb6_60",fi="_topMargin_qlcb6_66",pi="_bottomMargin_qlcb6_67",xi="_sideMargins_qlcb6_73",Z={panel:si,header:ii,title:li,headerActions:ai,content:ci,field:ui,horizontal:di,label:hi,marginsGrid:mi,topMargin:fi,bottomMargin:pi,sideMargins:xi},rn=({paper:e,onPaperChange:t})=>{const[n,s]=u.useState(!1),o=u.useCallback(d=>{d!==void 0&&s(d)},[]),l=u.useCallback(d=>{if(!d)return;const f=n?{top:d,right:d,bottom:d,left:d}:{...e.margin,top:d};t({...e,margin:f})},[e,t,n]),i=u.useCallback(d=>{d&&t({...e,margin:{...e.margin,right:d}})},[e,t]),a=u.useCallback(d=>{d&&t({...e,margin:{...e.margin,bottom:d}})},[e,t]),c=u.useCallback(d=>{d&&t({...e,margin:{...e.margin,left:d}})},[e,t]);return r.jsxs("div",{className:Z.panel,children:[r.jsxs("div",{className:Z.header,children:[r.jsx("h3",{className:Z.title,children:"マージン"}),r.jsx("div",{className:Z.headerActions,children:r.jsx(xe,{value:n,onChange:o,label:"全辺を一括設定"})})]}),r.jsx("div",{className:Z.content,children:n?r.jsxs("div",{className:`${Z.field} ${Z.horizontal}`,children:[r.jsx("span",{className:Z.label,children:"全辺"}),r.jsx(ne,{value:e.margin.top,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})]}):r.jsxs("div",{className:Z.marginsGrid,children:[r.jsx("div",{className:`${Z.field} ${Z.horizontal} ${Z.topMargin}`,children:r.jsx(ne,{value:e.margin.top,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsxs("div",{className:Z.sideMargins,children:[r.jsx("div",{className:`${Z.field} ${Z.horizontal}`,children:r.jsx(ne,{value:e.margin.left,onChange:c,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsx("div",{className:`${Z.field} ${Z.horizontal}`,children:r.jsx(ne,{value:e.margin.right,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]}),r.jsx("div",{className:`${Z.field} ${Z.horizontal} ${Z.bottomMargin}`,children:r.jsx(ne,{value:e.margin.bottom,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]})})]})};rn.displayName="MarginPanel";const bi="_panel_16d9o_6",vi="_title_16d9o_10",gi="_content_16d9o_22",wi="_field_16d9o_29",_i="_horizontal_16d9o_35",yi="_label_16d9o_41",Ei="_dimensionsRow_16d9o_52",fe={panel:bi,title:vi,content:gi,field:wi,horizontal:_i,label:yi,dimensionsRow:Ei},on=({paper:e,onPaperChange:t})=>{const n=u.useMemo(()=>[{value:pe.A4,label:"A4 (210 × 297 mm)"},{value:pe.A3,label:"A3 (297 × 420 mm)"},{value:pe.B5,label:"B5 (182 × 257 mm)"},{value:pe.LETTER,label:"Letter (8.5 × 11 inch)"},{value:pe.LEGAL,label:"Legal (8.5 × 14 inch)"},{value:pe.CUSTOM,label:"カスタム"}],[]),s=u.useCallback(a=>{if(!a)return;const c=Gt[a];t({...e,size:c})},[e,t]),o=u.useCallback(a=>{if(!a)return;const c={...e.size,preset:pe.CUSTOM,width:a};t({...e,size:c})},[e,t]),l=u.useCallback(a=>{if(!a)return;const c={...e.size,preset:pe.CUSTOM,height:a};t({...e,size:c})},[e,t]),i=e.size.preset===pe.CUSTOM;return r.jsxs("div",{className:fe.panel,children:[r.jsx("h3",{className:fe.title,children:"用紙サイズ"}),r.jsxs("div",{className:fe.content,children:[r.jsx("div",{className:fe.field,children:r.jsx(we,{value:e.size.preset,options:n,onChange:s})}),i&&r.jsxs("div",{className:fe.dimensionsRow,children:[r.jsxs("div",{className:`${fe.field} ${fe.horizontal}`,children:[r.jsx("span",{className:fe.label,children:"幅"}),r.jsx(ne,{value:e.size.width,onChange:o,allowedUnits:["mm","cm","inch"],min:1,max:1e4})]}),r.jsxs("div",{className:`${fe.field} ${fe.horizontal}`,children:[r.jsx("span",{className:fe.label,children:"高さ"}),r.jsx(ne,{value:e.size.height,onChange:l,allowedUnits:["mm","cm","inch"],min:1,max:1e4})]})]})]})]})};on.displayName="PaperSizePanel";const ji="_section_p4xnx_6",Ni="_title_p4xnx_14",Ii="_content_p4xnx_26",Di="_buttonGroup_p4xnx_33",$i="_button_p4xnx_33",Ti="_error_p4xnx_65",ee={section:ji,title:Ni,content:Ii,buttonGroup:Di,button:$i,error:Ti},sn=({schema:e,values:t,onSchemaChange:n,onValuesChange:s})=>{const[o,l]=u.useState(""),i=u.useRef(null),a=u.useRef(null),c=u.useCallback(()=>{try{const m=Tt(e,!0),w=new Blob([m],{type:"application/json"}),_=URL.createObjectURL(w),D=document.createElement("a");D.href=_,D.download="schema.json",D.click(),URL.revokeObjectURL(_),l("")}catch(m){l(`エクスポートエラー: ${m instanceof Error?m.message:String(m)}`)}},[e]),d=u.useCallback(async()=>{try{const m=Tt(e,!0);await navigator.clipboard.writeText(m),l(""),alert("スキーマをクリップボードにコピーしました")}catch(m){l(`クリップボードエラー: ${m instanceof Error?m.message:String(m)}`)}},[e]),f=u.useCallback(()=>{var m;(m=i.current)==null||m.click()},[]),x=u.useCallback(m=>{var D;const w=(D=m.target.files)==null?void 0:D[0];if(!w)return;const _=new FileReader;_.onload=A=>{var $;try{const j=($=A.target)==null?void 0:$.result,M=$t(j);n(M),l(""),alert("スキーマをインポートしました")}catch(j){l(`インポートエラー: ${j instanceof Error?j.message:String(j)}`)}},_.readAsText(w),m.target.value=""},[n]),b=u.useCallback(async()=>{try{const m=await navigator.clipboard.readText(),w=$t(m);n(w),l(""),alert("スキーマをインポートしました")}catch(m){l(`インポートエラー: ${m instanceof Error?m.message:String(m)}`)}},[n]),v=u.useCallback(()=>{try{const m=Rt(t,!0),w=new Blob([m],{type:"application/json"}),_=URL.createObjectURL(w),D=document.createElement("a");D.href=_,D.download="values.json",D.click(),URL.revokeObjectURL(_),l("")}catch(m){l(`エクスポートエラー: ${m instanceof Error?m.message:String(m)}`)}},[t]),E=u.useCallback(async()=>{try{const m=Rt(t,!0);await navigator.clipboard.writeText(m),l(""),alert("値をクリップボードにコピーしました")}catch(m){l(`クリップボードエラー: ${m instanceof Error?m.message:String(m)}`)}},[t]),y=u.useCallback(()=>{var m;(m=a.current)==null||m.click()},[]),h=u.useCallback(m=>{var D;const w=(D=m.target.files)==null?void 0:D[0];if(!w)return;const _=new FileReader;_.onload=A=>{var $;try{const j=($=A.target)==null?void 0:$.result,M=Ct(j);s(M),l(""),alert("値をインポートしました")}catch(j){l(`インポートエラー: ${j instanceof Error?j.message:String(j)}`)}},_.readAsText(w),m.target.value=""},[s]),p=u.useCallback(async()=>{try{const m=await navigator.clipboard.readText(),w=Ct(m);s(w),l(""),alert("値をインポートしました")}catch(m){l(`インポートエラー: ${m instanceof Error?m.message:String(m)}`)}},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:ee.section,children:[r.jsx("h3",{className:ee.title,children:"スキーマ"}),r.jsxs("div",{className:ee.content,children:[r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:c,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:d,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:f,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:b,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:i,type:"file",accept:".json",style:{display:"none"},onChange:x})]})]}),r.jsxs("div",{className:ee.section,children:[r.jsx("h3",{className:ee.title,children:"値"}),r.jsxs("div",{className:ee.content,children:[r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:v,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:E,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:y,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:p,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:a,type:"file",accept:".json",style:{display:"none"},onChange:h})]})]}),o&&r.jsx("div",{className:ee.error,role:"alert",children:o})]})};sn.displayName="ImportExportPanel";const ln=({schema:e,values:t,onSchemaChange:n,onValuesChange:s})=>r.jsx(At,{children:r.jsx(sn,{schema:e,values:t,onSchemaChange:n,onValuesChange:s})});ln.displayName="OtherPanel";const Ci="_container_naj39_3",Ri="_paletteItems_naj39_32",Mi="_item_naj39_44",ki="_itemPreview_naj39_77",Pi="_itemName_naj39_106",Fe={container:Ci,paletteItems:Ri,item:Mi,itemPreview:ki,itemName:Pi},an=({plugins:e,className:t})=>{const[n,s]=u.useState(null),o=u.useCallback((l,i)=>{s({plugin:l,mousePos:i,isOverCanvas:!1});const a=d=>{const f=document.elementFromPoint(d.clientX,d.clientY),x=!!(f!=null&&f.closest('[data-testid="interaction-layer"]'));s(b=>b?{...b,mousePos:{x:d.clientX,y:d.clientY},isOverCanvas:x}:null)},c=()=>{s(null),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",c)};window.addEventListener("pointermove",a),window.addEventListener("pointerup",c)},[]);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`${Fe.container} ${t||""}`,children:r.jsx("div",{className:Fe.paletteItems,children:e.map(l=>r.jsx(sr,{plugin:l,onDragStart:o},l.kind))})}),n&&!n.isOverCanvas&&r.jsx(ir,{plugin:n.plugin,mousePos:n.mousePos})]})};an.displayName="PalettePanel";const sr=({plugin:e,onDragStart:t})=>{const n=u.useMemo(()=>Ie(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),s=u.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),o=u.useCallback(l=>{l.preventDefault(),nt.start(e.kind,e.meta.defaultSize),t(e,{x:l.clientX,y:l.clientY});const i=()=>{nt.end(),window.removeEventListener("pointerup",i)};window.addEventListener("pointerup",i)},[e,t]);return r.jsxs("button",{type:"button",onPointerDown:o,className:Fe.item,"aria-label":`${e.meta.displayName}ブロックを追加`,children:[r.jsx("div",{className:Fe.itemName,children:e.meta.displayName}),r.jsx("div",{className:Fe.itemPreview,children:r.jsx(e.Renderer,{id:n.id,props:n.props,value:s,onChange:()=>{},readOnly:!0,mode:ce.FORM})})]})};sr.displayName="PaletteItem";const ir=({plugin:e,mousePos:t})=>{const n=u.useMemo(()=>Ie(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),s=u.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),o={width:e.meta.defaultSize.w*50,height:e.meta.defaultSize.h*50};return r.jsx("div",{"data-testid":"palette-drag-ghost",style:{position:"fixed",left:`${t.x-o.width/2}px`,top:`${t.y-o.height/2}px`,width:`${o.width}px`,height:`${o.height}px`,pointerEvents:"none",opacity:.5,filter:"grayscale(50%)",zIndex:9999,border:"2px dashed #3b82f6",backgroundColor:"#fff"},children:r.jsx(e.Renderer,{id:n.id,props:n.props,value:s,onChange:()=>{},readOnly:!0,mode:ce.FORM})})};ir.displayName="DragGhost";const Si="_container_rt0ql_3",Ai="_tabHeader_rt0ql_14",Li="_tabContent_rt0ql_21",Ue={container:Si,tabHeader:Ai,tabContent:Li},lr=({blocks:e,selectedBlockIds:t,pluginRegistry:n,onUpdateBlocks:s,schema:o,values:l,onSchemaChange:i,onValuesChange:a,gridSize:c,className:d})=>{const f=u.useMemo(()=>Object.values(n),[n]),x=u.useMemo(()=>e.filter(v=>t.includes(v.id)),[e,t]),b=t.length>0;return r.jsx("div",{className:`${Ue.container} ${d||""}`,children:r.jsxs(Lt,{defaultValue:"block",variant:"default",children:[r.jsxs(Ot,{className:Ue.tabHeader,children:[r.jsx(ye,{value:"block",children:"ブロック"}),r.jsx(ye,{value:"canvas",children:"キャンバス"}),r.jsx(ye,{value:"other",children:"その他"})]}),r.jsx(Ee,{value:"block",className:Ue.tabContent,children:b?r.jsx(Qt,{selectedBlocks:x,pluginRegistry:n,onUpdateBlocks:s,gridSize:c}):r.jsx(an,{plugins:f})}),r.jsx(Ee,{value:"canvas",className:Ue.tabContent,children:r.jsx(tn,{schema:o,onSchemaChange:i})}),r.jsx(Ee,{value:"other",className:Ue.tabContent,children:r.jsx(ln,{schema:o,values:l,onSchemaChange:i,onValuesChange:a})})]})})};lr.displayName="Sidebar";exports.ACTUAL_UNITS=to;exports.ALL_UNITS=eo;exports.BLOCK_SUB_INDEX=he;exports.BORDER_UNITS=gn;exports.BackgroundPanel=tr;exports.BlockBorder=Cn;exports.BlockCanvas=Rn;exports.BlockChangeType=ae;exports.BlockContainer=Vt;exports.BlockGuideBorder=kn;exports.BlockLayer=He;exports.BlockOrderPanel=en;exports.BlockPropertyPanel=Qt;exports.BlockRenderer=Ye;exports.Border=Ae;exports.BorderOverlay=Pn;exports.BorderPanel=nr;exports.BorderRenderer=De;exports.COLOR_PALETTE=vn;exports.CanvasPanel=tn;exports.Checkbox=xe;exports.ColorPalette=kt;exports.ColorPicker=ze;exports.ColorPickerPopover=St;exports.DEFAULT_DPI=W;exports.DEFAULT_GRID=jn;exports.DEFAULT_GUIDE_BORDER=ut;exports.DEFAULT_GUIDE_LINE=Mn;exports.DEFAULT_PAPER=Dn;exports.DEFAULT_PAPER_MARGIN=In;exports.DEFAULT_PAPER_SIZES=Gt;exports.DEFAULT_SCHEMA=bo;exports.DimensionInput=ne;exports.DragLayer=Kt;exports.DragType=oe;exports.EditingBlock=Xn;exports.FONT_UNITS=wn;exports.GRID_UNITS=ro;exports.GridCanvas=Sn;exports.GridDimensionLabel=et;exports.GridLayer=dt;exports.GridOverlay=Gn;exports.GridResizeHandle=tt;exports.GridSizePanel=nn;exports.HorizontalAlign=Ce;exports.ImageObjectFit=je;exports.ImportExportPanel=sn;exports.InsertGhost=Ft;exports.InteractionBlock=Le;exports.InteractionEventType=G;exports.InteractionLayer=qt;exports.InteractionMode=U;exports.LayoutPanel=rr;exports.LineType=de;exports.MarginOverlay=Bn;exports.MarginPanel=rn;exports.MetaPanel=or;exports.MovingGhost=Wt;exports.MultilineWhiteSpace=ke;exports.MultilineWordWrap=Me;exports.NoteEdit=Zt;exports.NoteEditor=er;exports.NoteForm=Jt;exports.NoteMode=ce;exports.NoteView=Qn;exports.NumberInput=ie;exports.OtherPanel=ln;exports.PADDING_UNITS=Te;exports.PAPER_UNITS=no;exports.PalettePanel=an;exports.PaperSizePanel=on;exports.PaperSizePreset=pe;exports.PluginPanels=Ss;exports.PropertyField=ft;exports.RESIZE_HANDLE_STYLE=ht;exports.RGBAInputs=Pt;exports.ResizeGhost=Ht;exports.ResizeHandle=H;exports.ResizeHandles=Ut;exports.SELECTION_STYLE=Ke;exports.SIZE_UNITS=Et;exports.Select=we;exports.SelectionBorder=Kn;exports.SelectionLayer=Xt;exports.Sidebar=lr;exports.TabPanel=At;exports.Tabs=Lt;exports.TabsContent=Ee;exports.TabsList=Ot;exports.TabsTrigger=ye;exports.TextInput=Se;exports.ValidationSeverity=$n;exports.VerticalAlign=Re;exports.Z_INDEX=B;exports.alignmentDefinition=xn;exports.assertFinite=mo;exports.assertInteger=ct;exports.assertNonNegative=Ne;exports.assertPositive=se;exports.assertRange=Nn;exports.binarySearch=Qe;exports.calculateGridResize=jt;exports.calculateResizedLayout=Yt;exports.clampBlockToGrid=Zn;exports.clampMultipleBlocks=zt;exports.cleanupPrint=Fn;exports.createBlock=Ie;exports.createBlockId=En;exports.createInitialProps=yn;exports.createPluginRegistry=io;exports.deserializeSchema=$t;exports.deserializeValues=Ct;exports.dimensionToString=Ln;exports.dimensionsToStrings=Mo;exports.distributeRemainder=Vn;exports.executePrint=Dt;exports.findBlockAtPoint=Mt;exports.findGridIndex=It;exports.fontStyleDefinition=so;exports.getBlockContainerStyle=Bt;exports.getBlockZIndex=Tn;exports.getCommonValue=be;exports.getMaxBlockCount=vo;exports.getMaxStep=Nt;exports.getPaperSize=Ho;exports.getStrokeDasharray=Pe;exports.getSubZIndex=We;exports.globalDragStore=nt;exports.gridToMms=ot;exports.gridToPxs=Yo;exports.imageDefinition=lo;exports.interactionZIndexs=J;exports.isValidHex=Gr;exports.mmsToPxs=st;exports.multilineDefinition=ao;exports.paddingDefinition=_n;exports.parseColor=yt;exports.placeholderDefinition=co;exports.preparePrint=Un;exports.removeUndefinedProps=it;exports.serializeSchema=Tt;exports.serializeValues=Rt;exports.sizeDefinition=uo;exports.stringToDimension=An;exports.stringsToDimensions=Do;exports.toHex=bn;exports.toMm=Y;exports.toPx=V;exports.toRgbaString=Or;exports.universalProperties=oo;exports.useGridCalc=mt;exports.useInteractionState=qn;exports.validateSchema=zn;exports.validateValues=Yn;exports.validationDefinition=ho;
32
+ `,document.head.appendChild(v),()=>{const m=document.getElementById("dynamic-print-page-style");m&&m.remove()}},[i]),u.useImperativeHandle(a,()=>({print:()=>{Dt({title:"Document"})},openPrintPreview:()=>{Dt({title:"Document"})}}),[]),r.jsxs("div",{ref:c,className:o,"data-print-mode":l,style:{position:"relative",width:`${d.canvas.width}px`,height:`${d.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:s!==1?`scale(${s})`:void 0,transformOrigin:"top center"},children:[r.jsx(dt,{paperPx:d,gridPosPxs:f,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(He,{blocks:e.blocks,pluginRegistry:n,mode:ce.VIEW,values:t,getBlockRectPx:x,showGuides:!1,showBorder:!0})]})};Qn.displayName="NoteView";const er=u.memo(u.forwardRef(Qn)),tr=u.memo(({schema:e,values:t,mode:n,pluginRegistry:s,onSchemaChange:o,onValuesChange:l,onSelectionChange:i,scale:a=1,className:c})=>{const d=u.useCallback((f,x)=>{if(l)if(x==null){const{[f]:b,...v}=t;l(v)}else l({...t,[f]:x})},[t,l]);return n===ce.FORM?r.jsx(Jt,{schema:e,pluginRegistry:s,onSchemaChange:o,onSelectionChange:i,scale:a,className:c}):n===ce.EDIT?r.jsx(Zt,{schema:e,values:t,pluginRegistry:s,onValueChange:d,scale:a,className:c}):r.jsx(er,{schema:e,values:t,pluginRegistry:s,scale:a,className:c})});tr.displayName="NoteEditor";function be(e,t){if(e.length===0)return;const n=(i,a)=>{let c=i;for(const d of a){if(c==null||typeof c!="object"||Array.isArray(c))return;c=c[d]}return c},s=t.split("."),o=n(e[0],s);return e.every(i=>n(i,s)===o)?o:void 0}const ss="_container_1tfjv_1",is="_row_1tfjv_20",ls="_inputWrapper_1tfjv_37",_t={container:ss,row:is,inputWrapper:ls},nr=({selectedBlocks:e,onUpdateBlocks:t})=>{if(e.length===0)return null;const n=s=>{const o={};e.forEach(l=>{o[l.id]={style:{...l.style,backgroundColor:s}}}),t(o)};return r.jsx("div",{className:_t.container,children:r.jsx("div",{className:_t.row,children:r.jsx("div",{className:_t.inputWrapper,children:r.jsx(ze,{value:be(e,"style.backgroundColor"),onChange:n,allowUndefined:!0,placeholder:"無色",height:24})})})})};function _e(e,t,n){const s=t.split("."),o=(l,i)=>{const a=s[i];if(i===s.length-1){if(n==null){const{[a]:f,...x}=l;return x}return{...l,[a]:n}}const c=(l==null?void 0:l[a])||{},d=o(c,i+1);if(Object.keys(d).length===0){const{[a]:f,...x}=l;return x}return{...l,[a]:d}};return o(e,0)}const rr=({selectedBlocks:e,onUpdateBlocks:t})=>{const n=(i,a,c)=>{const d={};e.forEach(f=>{var b,v,E;let x=_e(f.style||{},`border.${i}.${a}`,c);if(a==="type"&&c==null&&(x=_e(x,`border.${i}.width`,void 0),x=_e(x,`border.${i}.color`,void 0)),a==="type"&&c!==void 0&&c!==null){const y=(b=f.style)==null?void 0:b.border,h=y==null?void 0:y[i];h!=null&&h.width||(x=_e(x,`border.${i}.width`,{value:1,unit:"px"})),h!=null&&h.color||(x=_e(x,`border.${i}.color`,"#000000"))}if(a==="color"&&c!==void 0&&c!==null){const y=(v=f.style)==null?void 0:v.border,h=y==null?void 0:y[i];h!=null&&h.type||(x=_e(x,`border.${i}.type`,de.SOLID)),h!=null&&h.width||(x=_e(x,`border.${i}.width`,{value:1,unit:"px"}))}if(a==="width"&&c!==void 0&&c!==null){const y=(E=f.style)==null?void 0:E.border,h=y==null?void 0:y[i];h!=null&&h.type||(x=_e(x,`border.${i}.type`,de.SOLID)),h!=null&&h.color||(x=_e(x,`border.${i}.color`,"#000000"))}d[f.id]={style:x}}),t(d)},s=u.useMemo(()=>{var f;if(e.length!==1)return null;const i=e[0];if(!((f=i==null?void 0:i.style)!=null&&f.border))return null;const a=i.style.border;if(!a)return null;const c=x=>x?!(x.type&&!x.width):!0;return["all","top","right","bottom","left"].every(x=>c(a[x]))?new Se(a):null},[e]),o=i=>r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx(we,{value:be(e,`style.border.${i}.type`),onChange:a=>n(i,"type",a),placeholder:"スタイル",height:24,options:[{label:"",value:void 0},{label:"実線",value:de.SOLID},{label:"破線",value:de.DASHED},{label:"点線",value:de.DOTTED}]}),r.jsx(ne,{value:be(e,`style.border.${i}.width`),onChange:a=>n(i,"width",a),placeholder:"太さ",height:24,allowedUnits:gn,min:1}),r.jsx(ze,{value:be(e,`style.border.${i}.color`),onChange:a=>n(i,"color",a),placeholder:"色",height:24,allowUndefined:!0})]}),l={flex:1,padding:"0 2px",fontSize:"12px",minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"};return r.jsxs("div",{style:{display:"flex",flexDirection:"row",padding:"4px",alignItems:"stretch"},children:[r.jsx("div",{style:{flex:"0 0 30%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:r.jsxs("div",{style:{width:"80px",height:"80px",backgroundColor:"transparent",border:"transparent",borderRadius:"0.25rem",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[r.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",style:{position:"absolute",top:0,left:0,opacity:.3,pointerEvents:"none"},children:[r.jsx("title",{children:"枠線ガイド"}),r.jsx("line",{x1:"40",y1:"0",x2:"40",y2:"80",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"}),r.jsx("line",{x1:"0",y1:"40",x2:"80",y2:"40",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"})]}),s?r.jsx("div",{style:{position:"absolute",top:0,left:0,width:"80px",height:"80px",pointerEvents:"none"},children:r.jsx(De,{width:80,height:80,border:s})}):r.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",style:{position:"absolute",top:0,left:0,opacity:.3},children:[r.jsx("title",{children:"枠線未設定"}),r.jsx("rect",{x:"0",y:"0",width:"80",height:"80",fill:"none",stroke:"#9ca3af",strokeWidth:"1",strokeDasharray:"4 2"})]})]})}),r.jsx("div",{style:{flex:"0 0 70%",minWidth:0,padding:"0 0 2px 0"},children:r.jsxs(Lt,{defaultValue:"all",variant:"segmented",children:[r.jsx("div",{style:{width:"100%"},children:r.jsxs(Ot,{style:{width:"100%",display:"flex"},children:[r.jsx(ye,{value:"all",height:24,style:l,children:"共通"}),r.jsx(ye,{value:"top",height:24,style:l,children:"上"}),r.jsx(ye,{value:"bottom",height:24,style:l,children:"下"}),r.jsx(ye,{value:"left",height:24,style:l,children:"左"}),r.jsx(ye,{value:"right",height:24,style:l,children:"右"})]})}),r.jsxs("div",{style:{marginTop:"4px"},children:[r.jsx(Ee,{value:"all",children:o("all")}),r.jsx(Ee,{value:"top",children:o("top")}),r.jsx(Ee,{value:"bottom",children:o("bottom")}),r.jsx(Ee,{value:"left",children:o("left")}),r.jsx(Ee,{value:"right",children:o("right")})]})]})})]})},as="_container_1daw7_1",cs="_grid_1daw7_19",us="_field_1daw7_26",ds="_label_1daw7_33",hs="_inputWrapper_1daw7_43",le={container:as,grid:cs,field:us,label:ds,inputWrapper:hs},or=({selectedBlocks:e,onUpdateBlocks:t,gridSize:n})=>{if(e.length===0)return null;const s=e.length>1,o=s?Math.min(...e.map(a=>a.layout.x)):void 0,l=s?Math.min(...e.map(a=>a.layout.y)):void 0,i=(a,c)=>{if(c===void 0)return;const d={};if(s&&(a==="x"||a==="y")){const f=a==="x"?o:l;if(f===void 0)return;const x=Math.max(...e.map(p=>p.layout.x+p.layout.w)),b=Math.max(...e.map(p=>p.layout.y+p.layout.h)),v=x-(o??0),E=b-(l??0);let y=c;a==="x"&&n?y=Math.max(0,Math.min(c,n.cols-v)):a==="y"&&n?y=Math.max(0,Math.min(c,n.rows-E)):y=Math.max(0,c);const h=y-f;e.forEach(p=>{const m=p.layout[a]+h;d[p.id]={layout:{...p.layout,[a]:m}}})}else e.forEach(f=>{let x=c;if(a==="x"&&n)x=Math.max(0,Math.min(c,n.cols-f.layout.w));else if(a==="y"&&n)x=Math.max(0,Math.min(c,n.rows-f.layout.h));else if(a==="w"&&n){const b=n.cols-f.layout.x;x=Math.max(1,Math.min(c,b))}else if(a==="h"&&n){const b=n.rows-f.layout.y;x=Math.max(1,Math.min(c,b))}else a==="w"||a==="h"?x=Math.max(1,c):x=Math.max(0,c);d[f.id]={layout:{...f.layout,[a]:x}}});t(d)};return r.jsx("div",{className:le.container,children:r.jsxs("div",{className:le.grid,children:[r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"X"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:s?o:be(e,"layout.x"),onChange:a=>i("x",a),min:0,max:n?n.cols-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"Y"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:s?l:be(e,"layout.y"),onChange:a=>i("y",a),min:0,max:n?n.rows-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),!s&&r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"W"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:be(e,"layout.w"),onChange:a=>i("w",a),min:1,max:n==null?void 0:n.cols,integer:!0,height:22,placeholder:"-"})})]}),!s&&r.jsxs("div",{className:le.field,children:[r.jsx("span",{className:le.label,children:"H"}),r.jsx("div",{className:le.inputWrapper,children:r.jsx(ie,{value:be(e,"layout.h"),onChange:a=>i("h",a),min:1,max:n==null?void 0:n.rows,integer:!0,height:22,placeholder:"-"})})]})]})})},ms="_container_1h4w8_1",fs="_row_1h4w8_10",ps="_label_1h4w8_16",xs="_inputWrapper_1h4w8_25",$e={container:ms,row:fs,label:ps,inputWrapper:xs},sr=({selectedBlocks:e,onUpdateBlocks:t})=>{const[n,s]=u.useState(""),o=e[0];u.useEffect(()=>{e.length===1&&o&&s(o.id)},[e,o]);const l=()=>{if(!o)return;const c=o.id,d=n.trim();if(d===c||!d){s(c);return}t({[c]:{id:d}})},i=c=>{s(c??"")},a=c=>{const d={};e.forEach(f=>{d[f.id]={behavior:{...f.behavior,readOnly:!!c}}}),t(d)};return r.jsxs("div",{className:$e.container,children:[e.length===1&&r.jsxs("div",{className:$e.row,children:[r.jsx("span",{className:$e.label,children:"ID"}),r.jsx("div",{className:$e.inputWrapper,children:r.jsx(Ae,{value:n,onChange:i,onBlur:l,placeholder:"IDを入力",height:16})})]}),e.length>0&&r.jsx("div",{className:$e.row,children:r.jsx("div",{className:$e.inputWrapper,children:r.jsx(xe,{label:"読み取り専用",value:!!be(e,"behavior.readOnly"),onChange:a})})})]})},bs="_container_wa11y_1",vs="_scrollArea_wa11y_18",gs="_section_wa11y_26",ws="_sectionTitle_wa11y_35",_s="_subsection_wa11y_47",ys="_subsectionTitle_wa11y_51",Es="_fields_wa11y_59",js="_emptyState_wa11y_69",re={container:bs,scrollArea:vs,section:gs,sectionTitle:ws,subsection:_s,subsectionTitle:ys,fields:Es,emptyState:js},Ns="_field_qo0ef_1",Is="_label_qo0ef_7",Ds="_mixed_qo0ef_15",$s="_description_qo0ef_22",Je={field:Ns,label:Is,mixed:Ds,description:$s},ft=u.memo(({propertyKey:e,definition:t,selectedBlocks:n,onChange:s})=>{var f;const o=t.Component;if(!o)return null;const l=be(n,`props.${e}`),c=!n.map(x=>x.props[e]).every(x=>x===void 0)&&l===void 0&&n.length>1,d={value:c?void 0:l!==void 0?l:t.defaultValue,onChange:x=>s(e,x),readOnly:!1,config:{...t.config,placeholder:c?"複数選択中 (値が異なります)":(f=t.config)==null?void 0:f.placeholder}};return r.jsxs("div",{className:Je.field,children:[t.label&&r.jsx("div",{className:Je.label,title:t.description,children:t.label}),r.jsx(o,{...d}),c&&r.jsx("span",{className:Je.mixed,children:"(混在)"}),t.description&&r.jsx("p",{className:Je.description,children:t.description})]})});ft.displayName="PropertyField";function Ts(e){return e!==!1}const Qt=u.memo(({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n,gridSize:s,className:o=""})=>{const l=e[0],i=l?t[l.kind]:void 0,a=u.useMemo(()=>{var x;if(e.length===0)return!1;const f=(x=e[0])==null?void 0:x.kind;return e.every(b=>b.kind===f)},[e]),c=u.useMemo(()=>{if(!l||!i)return{};const f={};let x;if(a)x=Object.entries(i.properties);else{const b=e.map(h=>t[h.kind]).filter(h=>h!==void 0);if(b.length===0)return{};const v=b[0];if(!v)return{};const E=new Set(Object.keys(v.properties));x=Array.from(E).filter(h=>b.every(p=>h in p.properties)).map(h=>{const p=i.properties[h];return p?[h,p]:null}).filter(h=>h!==null)}return x.forEach(([b,v])=>{if(!Ts(v)||e.length>1&&v.disableInMultiSelection||v.condition&&!v.condition(l.props))return;const E=v.group||"基本";f[E]||(f[E]=[]),v.Component&&f[E].push({key:b,definition:v})}),f},[i,t,e,l,a]),d=(f,x)=>{const b={};e.forEach(v=>{b[v.id]={props:{...v.props,[f]:x}}}),n(b)};return e.length===0?r.jsx("div",{className:`${re.container} ${o}`,children:r.jsxs("div",{className:re.emptyState,children:["ブロックを選択すると",r.jsx("br",{}),"プロパティが表示されます"]})}):r.jsx("div",{className:`${re.container} ${o}`,children:r.jsxs("div",{className:re.scrollArea,children:[r.jsxs("div",{className:re.section,children:[r.jsx("div",{className:re.sectionTitle,children:"配置・サイズ"}),r.jsx(or,{selectedBlocks:e,onUpdateBlocks:n,gridSize:s})]}),r.jsxs("div",{className:re.section,children:[r.jsx("div",{className:re.sectionTitle,children:"背景"}),r.jsx(nr,{selectedBlocks:e,onUpdateBlocks:n})]}),r.jsxs("div",{className:re.section,children:[r.jsx("div",{className:re.sectionTitle,children:"枠線"}),r.jsx(rr,{selectedBlocks:e,onUpdateBlocks:n})]}),i&&Object.keys(c).length>0&&r.jsx("div",{className:re.section,children:Object.entries(c).map(([f,x])=>r.jsxs("div",{className:re.subsection,children:[r.jsx("div",{className:re.subsectionTitle,children:f}),r.jsx("div",{className:re.fields,children:x.map(({key:b,definition:v})=>r.jsx(ft,{propertyKey:b,definition:v,selectedBlocks:e,onChange:d},b))})]},f))}),r.jsxs("div",{className:re.section,children:[r.jsx("div",{className:re.sectionTitle,children:"基本設定"}),r.jsx(sr,{selectedBlocks:e,onUpdateBlocks:n})]})]})})});Qt.displayName="BlockPropertyPanel";const Rs="_panel_1h33v_1",Cs="_header_1h33v_11",Ms="_group_1h33v_18",ks="_groupTitle_1h33v_26",Ps="_groupContent_1h33v_36",Ve={panel:Rs,header:Cs,group:Ms,groupTitle:ks,groupContent:Ps};function As(e){return e!==!1}const Ss=({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n})=>{const s=e[0],o=s?t[s.kind]:void 0,l=u.useMemo(()=>{if(!s||!o)return{};const a={};return Object.entries(o.properties).forEach(([c,d])=>{if(!As(d)||e.length>1&&d.disableInMultiSelection||d.condition&&!d.condition(s.props))return;const f=d.group||"基本";a[f]||(a[f]=[]),d.Component&&a[f].push({key:c,definition:d})}),a},[o,e.length,s]),i=(a,c)=>{const d={};e.forEach(f=>{d[f.id]={props:{...f.props,[a]:c}}}),n(d)};return!s||!o||e.length===0?null:r.jsxs("div",{className:Ve.panel,children:[r.jsx("div",{className:Ve.header,children:e.length>1?`${e.length}個のブロック`:o.meta.displayName}),Object.entries(l).map(([a,c])=>r.jsxs("div",{className:Ve.group,children:[r.jsx("div",{className:Ve.groupTitle,children:a}),r.jsx("div",{className:Ve.groupContent,children:c.map(({key:d,definition:f})=>r.jsx(ft,{propertyKey:d,definition:f,selectedBlocks:e,onChange:i},d))})]},a))]})},Ls="_panel_1ekwd_6",Os="_title_1ekwd_10",Gs="_content_1ekwd_22",Bs="_description_1ekwd_29",Vs="_list_1ekwd_35",Us="_item_1ekwd_44",Fs="_dragging_1ekwd_61",zs="_dragOver_1ekwd_66",Ws="_dragHandle_1ekwd_71",Ys="_itemInfo_1ekwd_86",Hs="_itemId_1ekwd_93",Ks="_itemMeta_1ekwd_98",Xs="_itemKind_1ekwd_105",qs="_itemActions_1ekwd_113",Zs="_actionButton_1ekwd_118",Js="_empty_1ekwd_154",Q={panel:Ls,title:Os,content:Gs,description:Bs,list:Vs,item:Us,dragging:Fs,dragOver:zs,dragHandle:Ws,itemInfo:Ys,itemId:Hs,itemMeta:Ks,itemKind:Xs,itemActions:qs,actionButton:Zs,empty:Js},en=({blocks:e,onBlocksChange:t})=>{const[n,s]=u.useState(null),[o,l]=u.useState(null),i=[...e].reverse(),a=u.useCallback(h=>{const p=e.findIndex(_=>_.id===h);if(p===-1||p===e.length-1)return;const m=[...e],[w]=m.splice(p,1);w&&(m.push(w),t(m))},[e,t]),c=u.useCallback(h=>{const p=e.findIndex(_=>_.id===h);if(p===-1||p===0)return;const m=[...e],[w]=m.splice(p,1);w&&(m.unshift(w),t(m))},[e,t]),d=u.useCallback(h=>{const p=e.findIndex(D=>D.id===h);if(p===-1||p===e.length-1)return;const m=[...e],w=m[p],_=m[p+1];!w||!_||(m[p]=_,m[p+1]=w,t(m))},[e,t]),f=u.useCallback(h=>{const p=e.findIndex(D=>D.id===h);if(p===-1||p===0)return;const m=[...e],w=m[p],_=m[p-1];!w||!_||(m[p]=_,m[p-1]=w,t(m))},[e,t]),x=u.useCallback((h,p)=>{var w;s(p),h.dataTransfer.effectAllowed="move";const m=e.length-1-p;h.currentTarget&&h.dataTransfer.setData("text/plain",((w=e[m])==null?void 0:w.id)||"")},[e]),b=u.useCallback(()=>{s(null),l(null)},[]),v=u.useCallback((h,p)=>{h.preventDefault(),h.dataTransfer.dropEffect="move",!(n===null||n===p)&&l(p)},[n]),E=u.useCallback(()=>{l(null)},[]),y=u.useCallback((h,p)=>{if(h.preventDefault(),n===null||n===p){s(null),l(null);return}const m=e.length-1-n,w=e.length-1-p,_=[...e],[D]=_.splice(m,1);D&&(_.splice(w,0,D),t(_),s(null),l(null))},[e,n,t]);return r.jsxs("div",{className:Q.panel,children:[r.jsx("h3",{className:Q.title,children:"ブロック順序"}),r.jsxs("div",{className:Q.content,children:[r.jsx("p",{className:Q.description,children:"上が最前面、下が最背面"}),r.jsx("ul",{className:Q.list,children:i.map((h,p)=>{const m=e.length-1-p;return r.jsxs("li",{className:`${Q.item} ${n===p?Q.dragging:""} ${o===p?Q.dragOver:""}`,onDragOver:w=>v(w,p),onDragLeave:E,onDrop:w=>y(w,p),children:[r.jsx("button",{type:"button",className:Q.dragHandle,title:"ドラッグして並び替え",draggable:!0,onDragStart:w=>x(w,p),onDragEnd:b,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"ドラッグハンドル"}),r.jsx("circle",{cx:"6",cy:"4",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"4",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"6",cy:"8",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"8",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"6",cy:"12",r:"1",fill:"currentColor"}),r.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor"})]})}),r.jsxs("div",{className:Q.itemInfo,children:[r.jsx("div",{className:Q.itemId,children:h.id}),r.jsx("div",{className:Q.itemMeta,children:r.jsx("span",{className:Q.itemKind,children:h.kind})})]}),r.jsxs("div",{className:Q.itemActions,children:[r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>a(h.id),title:"最前面へ","aria-label":"最前面へ移動",disabled:m===e.length-1,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"最前面へ"}),r.jsx("path",{d:"M4 12v-8M8 12v-8M12 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M12 4h-8",stroke:"currentColor",strokeWidth:"2"})]})}),r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>d(h.id),title:"前面へ","aria-label":"前面へ移動",disabled:m===e.length-1,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"前面へ"}),r.jsx("path",{d:"M8 4v8",stroke:"currentColor"}),r.jsx("path",{d:"M5 7l3-3 3 3",stroke:"currentColor"})]})}),r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>f(h.id),title:"背面へ","aria-label":"背面へ移動",disabled:m===0,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"背面へ"}),r.jsx("path",{d:"M8 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M5 9l3 3 3-3",stroke:"currentColor"})]})}),r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>c(h.id),title:"最背面へ","aria-label":"最背面へ移動",disabled:m===0,children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[r.jsx("title",{children:"最背面へ"}),r.jsx("path",{d:"M4 12v-8M8 12v-8M12 12v-8",stroke:"currentColor"}),r.jsx("path",{d:"M12 12h-8",stroke:"currentColor",strokeWidth:"2"})]})})]})]},h.id)})}),e.length===0&&r.jsx("div",{className:Q.empty,children:"ブロックがありません"})]})]})};en.displayName="BlockOrderPanel";const tn=({schema:e,onSchemaChange:t})=>{const n=u.useCallback(l=>{t({...e,paper:l})},[e,t]),s=u.useCallback(l=>{t({...e,grid:l})},[e,t]),o=u.useCallback(l=>{t({...e,blocks:l})},[e,t]);return r.jsxs(St,{children:[r.jsx(on,{paper:e.paper,onPaperChange:n}),r.jsx(rn,{paper:e.paper,onPaperChange:n}),r.jsx(nn,{grid:e.grid,onGridChange:s}),r.jsx(en,{blocks:e.blocks,onBlocksChange:o})]})};tn.displayName="CanvasPanel";const Qs="_panel_1axyd_6",ei="_title_1axyd_10",ti="_content_1axyd_22",ni="_field_1axyd_29",ri="_horizontal_1axyd_35",oi="_label_1axyd_41",si="_gridSizeRow_1axyd_52",ge={panel:Qs,title:ei,content:ti,field:ni,horizontal:ri,label:oi,gridSizeRow:si},nn=({grid:e,onGridChange:t})=>{const n=u.useCallback(o=>{if(!o||o<1||o>100)return;const l=e.cols.length,i=[];if(o>l){i.push(...e.cols);for(let a=l;a<o;a++)i.push({value:1,unit:"fr"})}else i.push(...e.cols.slice(0,o));t({...e,cols:i})},[e,t]),s=u.useCallback(o=>{if(!o||o<1||o>100)return;const l=e.rows.length,i=[];if(o>l){i.push(...e.rows);for(let a=l;a<o;a++)i.push({value:1,unit:"fr"})}else i.push(...e.rows.slice(0,o));t({...e,rows:i})},[e,t]);return r.jsxs("div",{className:ge.panel,children:[r.jsx("h3",{className:ge.title,children:"グリッドサイズ"}),r.jsx("div",{className:ge.content,children:r.jsxs("div",{className:ge.gridSizeRow,children:[r.jsxs("div",{className:`${ge.field} ${ge.horizontal}`,children:[r.jsx("span",{className:ge.label,children:"列数"}),r.jsx(ie,{value:e.cols.length,onChange:n,min:1,max:100,step:1})]}),r.jsxs("div",{className:`${ge.field} ${ge.horizontal}`,children:[r.jsx("span",{className:ge.label,children:"行数"}),r.jsx(ie,{value:e.rows.length,onChange:s,min:1,max:100,step:1})]})]})})]})};nn.displayName="GridSizePanel";const ii="_panel_qlcb6_6",li="_header_qlcb6_10",ai="_title_qlcb6_20",ci="_headerActions_qlcb6_29",ui="_content_qlcb6_33",di="_field_qlcb6_37",hi="_horizontal_qlcb6_43",mi="_label_qlcb6_49",fi="_marginsGrid_qlcb6_60",pi="_topMargin_qlcb6_66",xi="_bottomMargin_qlcb6_67",bi="_sideMargins_qlcb6_73",Z={panel:ii,header:li,title:ai,headerActions:ci,content:ui,field:di,horizontal:hi,label:mi,marginsGrid:fi,topMargin:pi,bottomMargin:xi,sideMargins:bi},rn=({paper:e,onPaperChange:t})=>{const[n,s]=u.useState(!1),o=u.useCallback(d=>{d!==void 0&&s(d)},[]),l=u.useCallback(d=>{if(!d)return;const f=n?{top:d,right:d,bottom:d,left:d}:{...e.margin,top:d};t({...e,margin:f})},[e,t,n]),i=u.useCallback(d=>{d&&t({...e,margin:{...e.margin,right:d}})},[e,t]),a=u.useCallback(d=>{d&&t({...e,margin:{...e.margin,bottom:d}})},[e,t]),c=u.useCallback(d=>{d&&t({...e,margin:{...e.margin,left:d}})},[e,t]);return r.jsxs("div",{className:Z.panel,children:[r.jsxs("div",{className:Z.header,children:[r.jsx("h3",{className:Z.title,children:"マージン"}),r.jsx("div",{className:Z.headerActions,children:r.jsx(xe,{value:n,onChange:o,label:"全辺を一括設定"})})]}),r.jsx("div",{className:Z.content,children:n?r.jsxs("div",{className:`${Z.field} ${Z.horizontal}`,children:[r.jsx("span",{className:Z.label,children:"全辺"}),r.jsx(ne,{value:e.margin.top,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})]}):r.jsxs("div",{className:Z.marginsGrid,children:[r.jsx("div",{className:`${Z.field} ${Z.horizontal} ${Z.topMargin}`,children:r.jsx(ne,{value:e.margin.top,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsxs("div",{className:Z.sideMargins,children:[r.jsx("div",{className:`${Z.field} ${Z.horizontal}`,children:r.jsx(ne,{value:e.margin.left,onChange:c,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsx("div",{className:`${Z.field} ${Z.horizontal}`,children:r.jsx(ne,{value:e.margin.right,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]}),r.jsx("div",{className:`${Z.field} ${Z.horizontal} ${Z.bottomMargin}`,children:r.jsx(ne,{value:e.margin.bottom,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]})})]})};rn.displayName="MarginPanel";const vi="_panel_16d9o_6",gi="_title_16d9o_10",wi="_content_16d9o_22",_i="_field_16d9o_29",yi="_horizontal_16d9o_35",Ei="_label_16d9o_41",ji="_dimensionsRow_16d9o_52",fe={panel:vi,title:gi,content:wi,field:_i,horizontal:yi,label:Ei,dimensionsRow:ji},on=({paper:e,onPaperChange:t})=>{const n=u.useMemo(()=>[{value:pe.A4,label:"A4 (210 × 297 mm)"},{value:pe.A3,label:"A3 (297 × 420 mm)"},{value:pe.B5,label:"B5 (182 × 257 mm)"},{value:pe.LETTER,label:"Letter (8.5 × 11 inch)"},{value:pe.LEGAL,label:"Legal (8.5 × 14 inch)"},{value:pe.CUSTOM,label:"カスタム"}],[]),s=u.useCallback(a=>{if(!a)return;const c=Gt[a];t({...e,size:c})},[e,t]),o=u.useCallback(a=>{if(!a)return;const c={...e.size,preset:pe.CUSTOM,width:a};t({...e,size:c})},[e,t]),l=u.useCallback(a=>{if(!a)return;const c={...e.size,preset:pe.CUSTOM,height:a};t({...e,size:c})},[e,t]),i=e.size.preset===pe.CUSTOM;return r.jsxs("div",{className:fe.panel,children:[r.jsx("h3",{className:fe.title,children:"用紙サイズ"}),r.jsxs("div",{className:fe.content,children:[r.jsx("div",{className:fe.field,children:r.jsx(we,{value:e.size.preset,options:n,onChange:s})}),i&&r.jsxs("div",{className:fe.dimensionsRow,children:[r.jsxs("div",{className:`${fe.field} ${fe.horizontal}`,children:[r.jsx("span",{className:fe.label,children:"幅"}),r.jsx(ne,{value:e.size.width,onChange:o,allowedUnits:["mm","cm","inch"],min:1,max:1e4})]}),r.jsxs("div",{className:`${fe.field} ${fe.horizontal}`,children:[r.jsx("span",{className:fe.label,children:"高さ"}),r.jsx(ne,{value:e.size.height,onChange:l,allowedUnits:["mm","cm","inch"],min:1,max:1e4})]})]})]})]})};on.displayName="PaperSizePanel";const Ni="_section_p4xnx_6",Ii="_title_p4xnx_14",Di="_content_p4xnx_26",$i="_buttonGroup_p4xnx_33",Ti="_button_p4xnx_33",Ri="_error_p4xnx_65",ee={section:Ni,title:Ii,content:Di,buttonGroup:$i,button:Ti,error:Ri},sn=({schema:e,values:t,onSchemaChange:n,onValuesChange:s})=>{const[o,l]=u.useState(""),i=u.useRef(null),a=u.useRef(null),c=u.useCallback(()=>{try{const m=Tt(e,!0),w=new Blob([m],{type:"application/json"}),_=URL.createObjectURL(w),D=document.createElement("a");D.href=_,D.download="schema.json",D.click(),URL.revokeObjectURL(_),l("")}catch(m){l(`エクスポートエラー: ${m instanceof Error?m.message:String(m)}`)}},[e]),d=u.useCallback(async()=>{try{const m=Tt(e,!0);await navigator.clipboard.writeText(m),l(""),alert("スキーマをクリップボードにコピーしました")}catch(m){l(`クリップボードエラー: ${m instanceof Error?m.message:String(m)}`)}},[e]),f=u.useCallback(()=>{var m;(m=i.current)==null||m.click()},[]),x=u.useCallback(m=>{var D;const w=(D=m.target.files)==null?void 0:D[0];if(!w)return;const _=new FileReader;_.onload=S=>{var $;try{const j=($=S.target)==null?void 0:$.result,M=$t(j);n(M),l(""),alert("スキーマをインポートしました")}catch(j){l(`インポートエラー: ${j instanceof Error?j.message:String(j)}`)}},_.readAsText(w),m.target.value=""},[n]),b=u.useCallback(async()=>{try{const m=await navigator.clipboard.readText(),w=$t(m);n(w),l(""),alert("スキーマをインポートしました")}catch(m){l(`インポートエラー: ${m instanceof Error?m.message:String(m)}`)}},[n]),v=u.useCallback(()=>{try{const m=Ct(t,!0),w=new Blob([m],{type:"application/json"}),_=URL.createObjectURL(w),D=document.createElement("a");D.href=_,D.download="values.json",D.click(),URL.revokeObjectURL(_),l("")}catch(m){l(`エクスポートエラー: ${m instanceof Error?m.message:String(m)}`)}},[t]),E=u.useCallback(async()=>{try{const m=Ct(t,!0);await navigator.clipboard.writeText(m),l(""),alert("値をクリップボードにコピーしました")}catch(m){l(`クリップボードエラー: ${m instanceof Error?m.message:String(m)}`)}},[t]),y=u.useCallback(()=>{var m;(m=a.current)==null||m.click()},[]),h=u.useCallback(m=>{var D;const w=(D=m.target.files)==null?void 0:D[0];if(!w)return;const _=new FileReader;_.onload=S=>{var $;try{const j=($=S.target)==null?void 0:$.result,M=Rt(j);s(M),l(""),alert("値をインポートしました")}catch(j){l(`インポートエラー: ${j instanceof Error?j.message:String(j)}`)}},_.readAsText(w),m.target.value=""},[s]),p=u.useCallback(async()=>{try{const m=await navigator.clipboard.readText(),w=Rt(m);s(w),l(""),alert("値をインポートしました")}catch(m){l(`インポートエラー: ${m instanceof Error?m.message:String(m)}`)}},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:ee.section,children:[r.jsx("h3",{className:ee.title,children:"スキーマ"}),r.jsxs("div",{className:ee.content,children:[r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:c,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:d,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:f,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:b,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:i,type:"file",accept:".json",style:{display:"none"},onChange:x})]})]}),r.jsxs("div",{className:ee.section,children:[r.jsx("h3",{className:ee.title,children:"値"}),r.jsxs("div",{className:ee.content,children:[r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:v,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:E,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:ee.buttonGroup,children:[r.jsx("button",{type:"button",className:ee.button,onClick:y,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:p,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:a,type:"file",accept:".json",style:{display:"none"},onChange:h})]})]}),o&&r.jsx("div",{className:ee.error,role:"alert",children:o})]})};sn.displayName="ImportExportPanel";const ln=({schema:e,values:t,onSchemaChange:n,onValuesChange:s})=>r.jsx(St,{children:r.jsx(sn,{schema:e,values:t,onSchemaChange:n,onValuesChange:s})});ln.displayName="OtherPanel";const Ci="_container_naj39_3",Mi="_paletteItems_naj39_32",ki="_item_naj39_44",Pi="_itemPreview_naj39_77",Ai="_itemName_naj39_106",Fe={container:Ci,paletteItems:Mi,item:ki,itemPreview:Pi,itemName:Ai},an=({plugins:e,className:t})=>{const[n,s]=u.useState(null),o=u.useCallback((l,i)=>{s({plugin:l,mousePos:i,isOverCanvas:!1});const a=d=>{const f=document.elementFromPoint(d.clientX,d.clientY),x=!!(f!=null&&f.closest('[data-testid="interaction-layer"]'));s(b=>b?{...b,mousePos:{x:d.clientX,y:d.clientY},isOverCanvas:x}:null)},c=()=>{s(null),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",c)};window.addEventListener("pointermove",a),window.addEventListener("pointerup",c)},[]);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`${Fe.container} ${t||""}`,children:r.jsx("div",{className:Fe.paletteItems,children:e.map(l=>r.jsx(ir,{plugin:l,onDragStart:o},l.kind))})}),n&&!n.isOverCanvas&&r.jsx(lr,{plugin:n.plugin,mousePos:n.mousePos})]})};an.displayName="PalettePanel";const ir=({plugin:e,onDragStart:t})=>{const n=u.useMemo(()=>Ie(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),s=u.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),o=u.useCallback(l=>{l.preventDefault(),nt.start(e.kind,e.meta.defaultSize),t(e,{x:l.clientX,y:l.clientY});const i=()=>{nt.end(),window.removeEventListener("pointerup",i)};window.addEventListener("pointerup",i)},[e,t]);return r.jsxs("button",{type:"button",onPointerDown:o,className:Fe.item,"aria-label":`${e.meta.displayName}ブロックを追加`,children:[r.jsx("div",{className:Fe.itemName,children:e.meta.displayName}),r.jsx("div",{className:Fe.itemPreview,children:r.jsx(e.Renderer,{id:n.id,props:n.props,value:s,onChange:()=>{},readOnly:!0,mode:ce.FORM})})]})};ir.displayName="PaletteItem";const lr=({plugin:e,mousePos:t})=>{const n=u.useMemo(()=>Ie(e,{x:0,y:0,w:e.meta.defaultSize.w,h:e.meta.defaultSize.h},{}),[e]),s=u.useMemo(()=>{if(e.validateValue)return e.validateValue(void 0,n.props)},[e,n.props]),o={width:e.meta.defaultSize.w*50,height:e.meta.defaultSize.h*50};return r.jsx("div",{"data-testid":"palette-drag-ghost",style:{position:"fixed",left:`${t.x-o.width/2}px`,top:`${t.y-o.height/2}px`,width:`${o.width}px`,height:`${o.height}px`,pointerEvents:"none",opacity:.5,filter:"grayscale(50%)",zIndex:9999,border:"2px dashed #3b82f6",backgroundColor:"#fff"},children:r.jsx(e.Renderer,{id:n.id,props:n.props,value:s,onChange:()=>{},readOnly:!0,mode:ce.FORM})})};lr.displayName="DragGhost";const Si="_container_rt0ql_3",Li="_tabHeader_rt0ql_14",Oi="_tabContent_rt0ql_21",Ue={container:Si,tabHeader:Li,tabContent:Oi},ar=({blocks:e,selectedBlockIds:t,pluginRegistry:n,onUpdateBlocks:s,schema:o,values:l,onSchemaChange:i,onValuesChange:a,gridSize:c,className:d})=>{const f=u.useMemo(()=>Object.values(n),[n]),x=u.useMemo(()=>e.filter(v=>t.includes(v.id)),[e,t]),b=t.length>0;return r.jsx("div",{className:`${Ue.container} ${d||""}`,children:r.jsxs(Lt,{defaultValue:"block",variant:"default",children:[r.jsxs(Ot,{className:Ue.tabHeader,children:[r.jsx(ye,{value:"block",children:"ブロック"}),r.jsx(ye,{value:"canvas",children:"キャンバス"}),r.jsx(ye,{value:"other",children:"その他"})]}),r.jsx(Ee,{value:"block",className:Ue.tabContent,children:b?r.jsx(Qt,{selectedBlocks:x,pluginRegistry:n,onUpdateBlocks:s,gridSize:c}):r.jsx(an,{plugins:f})}),r.jsx(Ee,{value:"canvas",className:Ue.tabContent,children:r.jsx(tn,{schema:o,onSchemaChange:i})}),r.jsx(Ee,{value:"other",className:Ue.tabContent,children:r.jsx(ln,{schema:o,values:l,onSchemaChange:i,onValuesChange:a})})]})})};ar.displayName="Sidebar";exports.ACTUAL_UNITS=no;exports.ALL_UNITS=to;exports.BLOCK_SUB_INDEX=he;exports.BORDER_UNITS=gn;exports.BackgroundPanel=nr;exports.BlockBorder=Cn;exports.BlockCanvas=Mn;exports.BlockChangeType=ae;exports.BlockContainer=Vt;exports.BlockGuideBorder=Pn;exports.BlockLayer=He;exports.BlockOrderPanel=en;exports.BlockPropertyPanel=Qt;exports.BlockRenderer=Ye;exports.Border=Se;exports.BorderOverlay=An;exports.BorderPanel=rr;exports.BorderRenderer=De;exports.COLOR_PALETTE=vn;exports.CanvasPanel=tn;exports.Checkbox=xe;exports.ColorPalette=kt;exports.ColorPicker=ze;exports.ColorPickerPopover=At;exports.DEFAULT_DPI=W;exports.DEFAULT_FONT_FAMILY=yn;exports.DEFAULT_GRID=Nn;exports.DEFAULT_GUIDE_BORDER=ut;exports.DEFAULT_GUIDE_LINE=kn;exports.DEFAULT_PAPER=$n;exports.DEFAULT_PAPER_MARGIN=Dn;exports.DEFAULT_PAPER_SIZES=Gt;exports.DEFAULT_SCHEMA=vo;exports.DimensionInput=ne;exports.DragLayer=Kt;exports.DragType=oe;exports.EditingBlock=qn;exports.FONT_UNITS=wn;exports.GRID_UNITS=oo;exports.GridCanvas=Sn;exports.GridDimensionLabel=et;exports.GridLayer=dt;exports.GridOverlay=Bn;exports.GridResizeHandle=tt;exports.GridSizePanel=nn;exports.HorizontalAlign=Re;exports.ImageObjectFit=je;exports.ImportExportPanel=sn;exports.InsertGhost=Ft;exports.InteractionBlock=Le;exports.InteractionEventType=G;exports.InteractionLayer=qt;exports.InteractionMode=U;exports.LayoutPanel=or;exports.LineType=de;exports.MarginOverlay=Vn;exports.MarginPanel=rn;exports.MetaPanel=sr;exports.MovingGhost=Wt;exports.MultilineWhiteSpace=ke;exports.MultilineWordWrap=Me;exports.NoteEdit=Zt;exports.NoteEditor=tr;exports.NoteForm=Jt;exports.NoteMode=ce;exports.NoteView=er;exports.NumberInput=ie;exports.OtherPanel=ln;exports.PADDING_UNITS=Te;exports.PAPER_UNITS=ro;exports.PalettePanel=an;exports.PaperSizePanel=on;exports.PaperSizePreset=pe;exports.PluginPanels=Ss;exports.PropertyField=ft;exports.RESIZE_HANDLE_STYLE=ht;exports.RGBAInputs=Pt;exports.ResizeGhost=Ht;exports.ResizeHandle=H;exports.ResizeHandles=Ut;exports.SELECTION_STYLE=Ke;exports.SIZE_UNITS=Et;exports.Select=we;exports.SelectionBorder=Xn;exports.SelectionLayer=Xt;exports.Sidebar=ar;exports.TabPanel=St;exports.Tabs=Lt;exports.TabsContent=Ee;exports.TabsList=Ot;exports.TabsTrigger=ye;exports.TextInput=Ae;exports.ValidationSeverity=Tn;exports.VerticalAlign=Ce;exports.Z_INDEX=B;exports.alignmentDefinition=xn;exports.assertFinite=fo;exports.assertInteger=ct;exports.assertNonNegative=Ne;exports.assertPositive=se;exports.assertRange=In;exports.binarySearch=Qe;exports.calculateGridResize=jt;exports.calculateResizedLayout=Yt;exports.clampBlockToGrid=Jn;exports.clampMultipleBlocks=zt;exports.cleanupPrint=zn;exports.createBlock=Ie;exports.createBlockId=jn;exports.createInitialProps=En;exports.createPluginRegistry=lo;exports.deserializeSchema=$t;exports.deserializeValues=Rt;exports.dimensionToString=On;exports.dimensionsToStrings=ko;exports.distributeRemainder=Un;exports.executePrint=Dt;exports.findBlockAtPoint=Mt;exports.findGridIndex=It;exports.fontStyleDefinition=io;exports.getBlockContainerStyle=Bt;exports.getBlockZIndex=Rn;exports.getCommonValue=be;exports.getMaxBlockCount=go;exports.getMaxStep=Nt;exports.getPaperSize=Ko;exports.getStrokeDasharray=Pe;exports.getSubZIndex=We;exports.globalDragStore=nt;exports.gridToMms=ot;exports.gridToPxs=Ho;exports.imageDefinition=ao;exports.interactionZIndexs=J;exports.isValidHex=Br;exports.mmsToPxs=st;exports.multilineDefinition=co;exports.paddingDefinition=_n;exports.parseColor=yt;exports.placeholderDefinition=uo;exports.preparePrint=Fn;exports.removeUndefinedProps=it;exports.serializeSchema=Tt;exports.serializeValues=Ct;exports.sizeDefinition=ho;exports.stringToDimension=Ln;exports.stringsToDimensions=$o;exports.toHex=bn;exports.toMm=Y;exports.toPx=V;exports.toRgbaString=Gr;exports.universalProperties=so;exports.useGridCalc=mt;exports.useInteractionState=Zn;exports.validateSchema=Wn;exports.validateValues=Hn;exports.validationDefinition=mo;
33
33
  //# sourceMappingURL=index.js.map