@tatamicks/core 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2846 -2900
- package/dist/index.mjs.map +1 -1
- package/dist/src/index.d.ts +22 -25
- package/package.json +77 -77
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";require('./index.css');var
|
|
1
|
+
"use strict";require('./index.css');var gr=Object.defineProperty;var wr=(t,e,n)=>e in t?gr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var xe=(t,e,n)=>wr(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react");var Zt={exports:{}},Gt={};/**
|
|
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
|
|
9
|
+
*/var cn;function _r(){if(cn)return Gt;cn=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(o,s,i){var a=null;if(i!==void 0&&(a=""+i),s.key!==void 0&&(a=""+s.key),"key"in s){i={};for(var l in s)l!=="key"&&(i[l]=s[l])}else i=s;return s=i.ref,{$$typeof:t,type:o,key:a,ref:s!==void 0?s:null,props:i}}return Gt.Fragment=e,Gt.jsx=n,Gt.jsxs=n,Gt}var Bt={};/**
|
|
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
|
|
17
|
+
*/var un;function yr(){return un||(un=1,process.env.NODE_ENV!=="production"&&(function(){function t(b){if(b==null)return null;if(typeof b=="function")return b.$$typeof===D?null:b.displayName||b.name||null;if(typeof b=="string")return b;switch(b){case p:return"Fragment";case h:return"Profiler";case x:return"StrictMode";case B:return"Suspense";case $:return"SuspenseList";case S:return"Activity"}if(typeof b=="object")switch(typeof b.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),b.$$typeof){case y:return"Portal";case N:return b.displayName||"Context";case w:return(b._context.displayName||"Context")+".Consumer";case I:var M=b.render;return b=b.displayName,b||(b=M.displayName||M.name||"",b=b!==""?"ForwardRef("+b+")":"ForwardRef"),b;case A:return M=b.displayName||null,M!==null?M:t(b.type)||"Memo";case L:M=b._payload,b=b._init;try{return t(b(M))}catch{}}return null}function e(b){return""+b}function n(b){try{e(b);var M=!1}catch{M=!0}if(M){M=console;var P=M.error,z=typeof Symbol=="function"&&Symbol.toStringTag&&b[Symbol.toStringTag]||b.constructor.name||"Object";return P.call(M,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",z),e(b)}}function o(b){if(b===p)return"<>";if(typeof b=="object"&&b!==null&&b.$$typeof===L)return"<...>";try{var M=t(b);return M?"<"+M+">":"<...>"}catch{return"<...>"}}function s(){var b=k.A;return b===null?null:b.getOwner()}function i(){return Error("react-stack-top-frame")}function a(b){if(C.call(b,"key")){var M=Object.getOwnPropertyDescriptor(b,"key").get;if(M&&M.isReactWarning)return!1}return b.key!==void 0}function l(b,M){function P(){R||(R=!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)",M))}P.isReactWarning=!0,Object.defineProperty(b,"key",{get:P,configurable:!0})}function c(){var b=t(this.type);return T[b]||(T[b]=!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.")),b=this.props.ref,b!==void 0?b:null}function m(b,M,P,z,ht,Ot){var q=P.ref;return b={$$typeof:E,type:b,key:M,props:P,_owner:z},(q!==void 0?q:null)!==null?Object.defineProperty(b,"ref",{enumerable:!1,get:c}):Object.defineProperty(b,"ref",{enumerable:!1,value:null}),b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(b,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(b,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ht}),Object.defineProperty(b,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Ot}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b}function d(b,M,P,z,ht,Ot){var q=M.children;if(q!==void 0)if(z)if(j(q)){for(z=0;z<q.length;z++)f(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 f(q);if(C.call(M,"key")){q=t(b);var ut=Object.keys(M).filter(function(Kt){return Kt!=="key"});z=0<ut.length?"{key: someKey, "+ut.join(": ..., ")+": ...}":"{key: someKey}",F[q+z]||(ut=0<ut.length?"{"+ut.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,Z,ue,Z),X[Z+z]=!0)}if(Z=null,A!==void 0&&(n(A),Z=""+A),i(C)&&(n(C.key),Z=""+C.key),"key"in C){A={};for(var be in C)be!=="key"&&(A[be]=C[be])}else A=C;return Z&&l(A,typeof v=="function"?v.displayName||v.name||"Unknown":v),d(v,Z,A,o(),he,Oe)}function x(v){g(v)?v._store&&(v._store.validated=1):typeof v=="object"&&v!==null&&v.$$typeof===T&&(v._payload.status==="fulfilled"?g(v._payload.value)&&v._payload.value._store&&(v._payload.value._store.validated=1):v._store&&(v._store.validated=1))}function g(v){return typeof v=="object"&&v!==null&&v.$$typeof===j}var b=u,j=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),I=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),O=Symbol.for("react.client.reference"),R=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,N=Array.isArray,D=console.createTask?console.createTask:function(){return null};b={react_stack_bottom_frame:function(v){return v()}};var P,S={},F=b.react_stack_bottom_frame.bind(b,a)(),K=D(s(a)),X={};Be.Fragment=f,Be.jsx=function(v,C,A){var z=1e4>R.recentlyCreatedOwnerStacks++;return m(v,C,A,!1,z?Error("react-stack-top-frame"):F,z?D(s(v)):K)},Be.jsxs=function(v,C,A){var z=1e4>R.recentlyCreatedOwnerStacks++;return m(v,C,A,!0,z?Error("react-stack-top-frame"):F,z?D(s(v)):K)}})()),Be}var un;function yr(){return un||(un=1,process.env.NODE_ENV==="production"?qe.exports=_r():qe.exports=wr()),qe.exports}var r=yr(),Te=(e=>(e.left="flex-start",e.center="center",e.right="flex-end",e))(Te||{}),Ce=(e=>(e.top="flex-start",e.center="center",e.bottom="flex-end",e))(Ce||{});const Er="_container_gerw7_9",jr="_select_gerw7_21",Nr="_placeholderOverlay_gerw7_87",xt={container:Er,select:jr,placeholderOverlay:Nr},_e=e=>{const{value:t,onChange:n,readOnly:s=!1,config:o}=e,a=e.options??(o==null?void 0:o.options)??[],i=e.placeholder??(o==null?void 0:o.placeholder)??"選択してください",l=e.width??(o==null?void 0:o.width),c=e.height??(o==null?void 0:o.height),d=u.useCallback(j=>{const y=j.target.value;if(y==="")n(void 0);else{const f=a.find(p=>String(p.value)===y);n(f?f.value:y)}},[n,a]),m=t??"",x=t!==void 0&&t!=="",g={};l!==void 0?g.width=`${l}px`:g.width="100%";const b={width:"100%",height:c?`${c}px`:void 0};return r.jsxs("div",{className:xt.container,style:g,children:[!x&&r.jsx("input",{className:xt.placeholderOverlay,style:b,readOnly:!0,placeholder:i}),r.jsx("select",{className:xt.select,style:b,value:m,onChange:d,disabled:s,children:a.map(j=>r.jsx("option",{value:String(j.value),children:j.label},String(j.value)))})]})};_e.displayName="Select";const fn={justifyContent:{defaultValue:Te.left,label:"水平方向の配置",group:"配置",description:"ブロック内のコンテンツの水平方向の配置を設定します。",Component:_e,config:{options:[{label:"左揃え",value:Te.left},{label:"中央揃え",value:Te.center},{label:"右揃え",value:Te.right}]}},alignItems:{defaultValue:Ce.center,label:"垂直方向の配置",group:"配置",description:"ブロック内のコンテンツの垂直方向の配置を設定します。",Component:_e,config:{options:[{label:"上揃え",value:Ce.top},{label:"中央揃え",value:Ce.center},{label:"下揃え",value:Ce.bottom}]}}},Ir="_container_6u83k_9",Dr="_input_6u83k_25",$r="_label_6u83k_57",gt={container:Ir,input:Dr,label:$r},xe=({value:e,onChange:t,readOnly:n=!1,label:s,config:o})=>{const a=s??(o==null?void 0:o.label),i=u.useCallback(l=>{t(l.target.checked)},[t]);return r.jsxs("label",{className:gt.container,children:[r.jsx("input",{type:"checkbox",className:gt.input,checked:!!e,onChange:i,disabled:n}),a&&r.jsx("span",{className:gt.label,children:a})]})};xe.displayName="Checkbox";const Tr="_container_1gj1n_9",Cr="_colorButton_1gj1n_25",Rr="_textInputWrapper_1gj1n_79",Mr="_textInputPrefix_1gj1n_123",kr="_textInput_1gj1n_79",Pr="_popover_1gj1n_249",Ar="_palette_1gj1n_281",Sr="_paletteButton_1gj1n_295",Lr="_selected_1gj1n_341",Or="_transparentPaletteButton_1gj1n_353",Gr="_rgbaInputs_1gj1n_365",Br="_rgbaInputGroup_1gj1n_379",Vr="_rgbaLabel_1gj1n_409",te={container:Tr,colorButton:Cr,textInputWrapper:Rr,textInputPrefix:Mr,textInput:kr,popover:Pr,palette:Ar,paletteButton:Sr,selected:Lr,transparentPaletteButton:Or,rgbaInputs:Gr,rgbaInputGroup:Br,rgbaLabel:Vr};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),a=Number.parseInt(s.slice(2,4),16),i=Number.parseInt(s.slice(4,6),16),l=s.length===8?Number.parseInt(s.slice(6,8),16)/255:1;return{r:o,g:a,b:i,a:l}}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),a=Number.parseInt(n[3]??"",10),i=n[4]?Number.parseFloat(n[4]):1;return{r:s,g:o,b:a,a:i}}return null}function pn(e){const{r:t,g:n,b:s,a:o}=e;if(o===0)return;const a=t.toString(16).padStart(2,"0"),i=n.toString(16).padStart(2,"0"),l=s.toString(16).padStart(2,"0");if(o<1){const c=Math.round(o*255).toString(16).padStart(2,"0");return`#${a}${i}${l}${c}`}return`#${a}${i}${l}`}function Ur(e){const{r:t,g:n,b:s,a:o}=e;if(o!==0)return`rgba(${t}, ${n}, ${s}, ${o})`}function Fr(e){return/^#([0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)}const xn=[{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:xn.map((s,o)=>{const a=s.value===void 0,i=s.value===t,l=a?{}:{backgroundColor:s.value};return r.jsx("button",{type:"button",className:`${te.paletteButton} ${a?te.transparentPaletteButton:""} ${i?te.selected:""}`,onClick:()=>e(s.value),disabled:n,title:s.label,"aria-label":s.label,style:l},s.value??`undefined-${o}`)})});kt.displayName="ColorPalette";const zr="_input_me6tq_9",Wr={input:zr},ie=({value:e,onChange:t,readOnly:n=!1,min:s,max:o,step:a,integer:i,placeholder:l,width:c,height:d,config:m,onBlur:x})=>{const g=s??(m==null?void 0:m.min)??1,b=o??(m==null?void 0:m.max),j=a??(m==null?void 0:m.step)??1,y=i??(m==null?void 0:m.integer)??!1,f=l??(m==null?void 0:m.placeholder),p=c??(m==null?void 0:m.width),h=d??(m==null?void 0:m.height),_=u.useCallback(E=>{const M=E.target.value;if(M===""){t(void 0);return}let $=Number.parseFloat(M);Number.isNaN($)||(y&&($=Math.round($)),g!==void 0&&$<g&&($=g),b!==void 0&&$>b&&($=b),t($))},[t,g,b,y]),I={};return p!==void 0&&(I.width=`${p}px`),h!==void 0&&(I.height=`${h}px`,I.paddingTop=0,I.paddingBottom=0),r.jsx("input",{type:"number",className:Wr.input,style:I,value:e??"",onChange:_,onBlur:x,disabled:n,min:g,max:b,step:j,placeholder:f})};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},me={BG:10,CONTENT:50,GUIDE:70,BORDER:80},At=({isOpen:e,onClose:t,rgba:n,onRgbaChange:s,onColorSelect:o,selectedColor:a,readOnly:i=!1})=>{const l=u.useRef(null);return u.useEffect(()=>{if(!e)return;const c=d=>{l.current&&!l.current.contains(d.target)&&t()};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[e,t]),e?r.jsxs("div",{className:te.popover,ref:l,style:{zIndex:B.DROPDOWN},children:[r.jsx(kt,{onColorSelect:o,selectedColor:a,readOnly:i}),r.jsx(Pt,{rgba:n,onChange:s,readOnly:i})]}):null};At.displayName="ColorPickerPopover";const We=({value:e,onChange:t,readOnly:n=!1,showTextInput:s=!0,allowUndefined:o,placeholder:a,width:i,height:l,config:c})=>{const d=o??(c==null?void 0:c.allowUndefined)??!0,m=a??(d?"未設定":"#000000"),x=i??(c==null?void 0:c.width),g=l??(c==null?void 0:c.height),[b,j]=u.useState(!1),y=u.useRef(null),[f,p]=u.useState(()=>yt(e)??{r:0,g:0,b:0,a:1});u.useEffect(()=>{const N=yt(e);N&&p(N)},[e]);const h=u.useCallback(()=>{n||j(N=>!N)},[n]),[_,I]=u.useState(e?e.replace(/^#/,""):"");u.useEffect(()=>{I(e?e.replace(/^#/,""):"")},[e]);const E=u.useCallback(N=>{const D=N.target.value;/^[0-9A-Fa-f]*$/.test(D)&&I(D)},[]),M=u.useCallback(N=>{if(N===""&&d){t(void 0);return}/^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(N)?t(`#${N}`):I(e?e.replace(/^#/,""):"")},[t,d,e]),$=u.useCallback(N=>{M(N.target.value)},[M]),w=u.useCallback(N=>{N.key==="Enter"&&(N.preventDefault(),M(N.currentTarget.value),N.currentTarget.blur())},[M]),T=u.useCallback(N=>{t(N)},[t]),k=u.useCallback((N,D)=>{if(D===void 0)return;const P={...f,[N]:D};p(P),t(pn(P))},[f,t]),O=e??"未設定",R={};e&&(R.background=e);const L={};return x!==void 0?L.width=`${x}px`:L.width="100%",g!==void 0&&(L.height=`${g}px`),r.jsxs("div",{className:te.container,style:L,ref:y,children:[r.jsx("button",{type:"button",className:te.colorButton,onClick:h,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:_,onChange:E,onKeyDown:w,onBlur:$,disabled:n,placeholder:m,maxLength:8})]}),r.jsx(At,{isOpen:b,onClose:()=>j(!1),rgba:f,onRgbaChange:k,onColorSelect:T,selectedColor:e,readOnly:n})]})};We.displayName="ColorPicker";const Yr="_container_3qavu_9",Hr="_valueInput_3qavu_45",Kr="_unitSelect_3qavu_89",bt={container:Yr,valueInput:Hr,unitSelect:Kr},oe=e=>{const{value:t,onChange:n,readOnly:s=!1,config:o}=e,a=e.allowedUnits??(o==null?void 0:o.allowedUnits),i=e.min??(o==null?void 0:o.min),l=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),m=e.width??(o==null?void 0:o.width),x=e.height??(o==null?void 0:o.height),g=(t==null?void 0:t.unit)??(a==null?void 0:a[0]),b=u.useCallback(_=>{const I=_.target.value;let E=Number.parseFloat(I);if(Number.isNaN(E))return;const M=i??1;E<M&&(E=M),l!==void 0&&E>l&&(E=l),n({value:E,unit:(t==null?void 0:t.unit)??g})},[t,n,g,i,l]),j=u.useCallback(_=>{const I=_.target.value;if(I==="")return;let E=Number.parseFloat(I);if(Number.isNaN(E))return;const M=i??1;E<M&&(E=M,n({value:E,unit:(t==null?void 0:t.unit)??g})),l!==void 0&&E>l&&(E=l,n({value:E,unit:(t==null?void 0:t.unit)??g}))},[t,n,g,i,l]),y=u.useCallback(_=>{const I=_.target.value;n({value:(t==null?void 0:t.value)??1,unit:I})},[t,n]),f=(t==null?void 0:t.value)??"",p=(t==null?void 0:t.unit)??g??"",h={};return m!==void 0?h.width=`${m}px`:h.width="100%",x!==void 0&&(h.height=`${x}px`),r.jsxs("div",{className:bt.container,style:h,children:[r.jsx("input",{type:"number",className:bt.valueInput,value:f,onChange:b,onBlur:j,placeholder:d,min:i??1,max:l,step:c,readOnly:s,disabled:s}),r.jsx("select",{className:bt.unitSelect,value:p,onChange:y,disabled:s||!a||a.length<=1,children:a?a.map(_=>r.jsx("option",{value:_,children:_},_)):r.jsx("option",{value:p,children:p})})]})},Xr="_container_1sn14_11",Zr="_scrollArea_1sn14_45",qr="_emptyState_1sn14_61",vt={container:Xr,scrollArea:Zr,emptyState:qr},St=({children:e,emptyMessage:t,className:n})=>r.jsx("div",{className:`${vt.container} ${n||""}`,children:e?r.jsx("div",{className:vt.scrollArea,children:e}):t&&r.jsx("div",{className:vt.emptyState,children:t})}),Jr="_root_kb3dm_5",Qr="_list_kb3dm_21",eo="_trigger_kb3dm_51",to="_content_kb3dm_141",at={root:Jr,list:Qr,trigger:eo,content:to},lt=u.createContext(void 0),Lt=({defaultValue:e,value:t,onValueChange:n,children:s,variant:o="default",className:a=""})=>{const[i,l]=u.useState(e),c=t??i,d=m=>{l(m),n==null||n(m)};return r.jsx(lt.Provider,{value:{value:c,onChange:d,variant:o},children:r.jsx("div",{className:`${at.root} ${a}`,"data-variant":o,children:s})})},Ot=({children:e,className:t="",width:n,height:s,style:o})=>{const a=u.useContext(lt);if(!a)throw new Error("TabsList must be used within a Tabs component");const{variant:i}=a,l={...o};return n!==void 0&&(l.width=`${n}px`),s!==void 0&&(l.height=`${s}px`),r.jsx("div",{className:`${at.list} ${t}`,"data-variant":i,style:l,children:e})},ye=({value:e,children:t,className:n="",disabled:s=!1,width:o,height:a,style:i})=>{const l=u.useContext(lt);if(!l)throw new Error("TabsTrigger must be used within a Tabs component");const{value:c,onChange:d,variant:m}=l,x=c===e,g={...i};return o!==void 0&&(g.width=`${o}px`),a!==void 0&&(g.height=`${a}px`),r.jsx("button",{className:`${at.trigger} ${n}`,"data-state":x?"active":"inactive","data-variant":m,onClick:()=>d(e),disabled:s,type:"button",style:g,children:t})},Ee=({value:e,children:t,className:n=""})=>{const s=u.useContext(lt);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:`${at.content} ${n}`,children:t})},no="_input_hr2wj_9",ro={input:no},Pe=({value:e,onChange:t,readOnly:n=!1,placeholder:s,maxLength:o,multiline:a,rows:i,width:l,height:c,config:d,onBlur:m})=>{const x=s??(d==null?void 0:d.placeholder),g=o??(d==null?void 0:d.maxLength),b=a??(d==null?void 0:d.multiline)??!1,j=i??(d==null?void 0:d.rows)??3,y=u.useCallback(h=>{const _=h.target.value;t(_)},[t]),f={};l!==void 0?f.width=`${l}px`:f.width="100%",c!==void 0&&(f.height=`${c}px`);const p={className:ro.input,style:f,value:e??"",onChange:y,disabled:n,placeholder:x,maxLength:g};return b?r.jsx("textarea",{...p,rows:j}):r.jsx("input",{...p,type:"text",onBlur:m})};Pe.displayName="TextInput";const oo=["mm","cm","fr","inch","pt","px","%"],so=["mm","cm","pt","inch","px"],io=["mm","cm","inch"],ao=["mm","cm","fr","inch","pt","px"],gn=["px","pt","mm"],bn=["px","pt","mm"],$e=["mm","pt","px","%"],Et=["mm","cm","inch","pt","px","%"],vn={isIndividual:{defaultValue:!1,label:"個別に設定",group:"余白",Component:xe,description:"上下左右の余白を個別に設定します"},all:{defaultValue:{value:10,unit:"px"},label:"全方向",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>!e.isIndividual},top:{defaultValue:{value:10,unit:"px"},label:"上",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>e.isIndividual===!0},right:{defaultValue:{value:10,unit:"px"},label:"右",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>e.isIndividual===!0},bottom:{defaultValue:{value:10,unit:"px"},label:"下",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>e.isIndividual===!0},left:{defaultValue:{value:10,unit:"px"},label:"左",group:"余白",Component:oe,config:{allowedUnits:$e,min:0},condition:e=>e.isIndividual===!0}},lo={...fn,...vn},_n=[{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"}],co={fontSize:{defaultValue:{value:14,unit:"pt"},label:"フォントサイズ",group:"フォント",description:"テキストのフォントサイズを設定します",Component:oe,config:{allowedUnits:bn,min:1,step:1}},fontFamily:{defaultValue:"sans-serif",label:"フォント",group:"フォント",Component:_e,config:{placeholder:"フォントを選択",options:_n}},color:{defaultValue:void 0,label:"文字色",group:"フォント",Component:We,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 uo(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 mo={objectFit:{defaultValue:je.Contain,label:"表示方法",group:"画像",description:"画像のサイズが枠と合わない場合の表示方法を設定します",Component:_e,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:Pe,config:{placeholder:"画像の説明"}}};var Re=(e=>(e.Normal="normal",e.BreakWord="break-word",e.BreakAll="break-all",e))(Re||{}),Me=(e=>(e.Normal="normal",e.NoWrap="nowrap",e.Pre="pre",e.PreWrap="pre-wrap",e.PreLine="pre-line",e))(Me||{});const ho={multiline:{defaultValue:!1,label:"複数行モード",group:"設定",Component:xe,config:{label:"有効にする"}},wordWrap:{defaultValue:Re.Normal,label:"単語の折り返し",group:"設定",Component:_e,config:{options:[{label:"通常",value:Re.Normal},{label:"単語で改行",value:Re.BreakWord},{label:"強制改行",value:Re.BreakAll}]},condition:e=>e.multiline===!0},whiteSpace:{defaultValue:Me.Normal,label:"空白文字の扱い",group:"設定",Component:_e,config:{options:[{label:"通常",value:Me.Normal},{label:"折り返しなし",value:Me.NoWrap},{label:"そのまま表示",value:Me.Pre}]},condition:e=>e.multiline===!0}},fo={placeholder:{defaultValue:void 0,label:"プレースホルダー",group:"設定",description:"入力欄に表示するプレースホルダーテキストを設定します",Component:Pe,config:{placeholder:"例: テキストを入力してください"}}},po={width:{defaultValue:void 0,label:"幅",group:"サイズ",description:"要素の幅を設定します",Component:oe,config:{min:0,allowedUnits:Et,placeholder:"auto"}},height:{defaultValue:void 0,label:"高さ",group:"サイズ",description:"要素の高さを設定します",Component:oe,config:{min:0,allowedUnits:Et,placeholder:"auto"}}},wn=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 yn(e){const t=Date.now(),n=Math.random().toString(36).slice(2);return`${e}_${t}_${n}`}function Ne(e,t,n){const s=wn(e);return{id:yn(e.kind),kind:e.kind,layout:{x:t.x,y:t.y,w:t.w,h:t.h},style:{},behavior:{},props:{...s,...n}}}const xo={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:Pe,config:{placeholder:"例: ^[0-9]+$"},disableInMultiSelection:!0}};var ce=(e=>(e.ADD="add",e.UPDATE="update",e.DELETE="delete",e.MOVE="move",e.RESIZE="resize",e.DUPLICATE="duplicate",e.PASTE="paste",e))(ce||{});const En={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 ct(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 jn(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 ut(e,t){if(!Number.isInteger(e)){const n=t??"Value";throw new Error(`${n} must be an integer: got ${e}`)}}function go(e,t){if(!Number.isFinite(e)){const n=t??"Value";throw new Error(`${n} must be a finite number: got ${e}`)}}const bo=25.4,vo=2.54,_o=72,V={_assertDpi(e){ct(e,"DPI"),ut(e,"DPI")},fromMm(e,t=W){return V._assertDpi(t),ne(e,"Millimeter value"),e*t/bo},fromCm(e,t=W){return V._assertDpi(t),ne(e,"Centimeter value"),e*t/vo},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/_o},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}`)}}}},ke=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:ke(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:ke(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:ke(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:ke(s),vectorEffect:"non-scaling-stroke","data-edge":"left"}:null}}var ae=(e=>(e.FORM="Form",e.EDIT="Edit",e.VIEW="View",e))(ae||{}),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"}}},Nn={top:{value:10,unit:"mm"},right:{value:10,unit:"mm"},bottom:{value:10,unit:"mm"},left:{value:10,unit:"mm"}},In={size:Gt.A4,margin:Nn},wo={paper:In,grid:En,blocks:[]};var Dn=(e=>(e.ERROR="error",e.WARNING="warning",e.INFO="info",e))(Dn||{});const Ie=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);Ie.displayName="BorderRenderer";function $n(e){const t=B.BLOCK_LAYER_MIN+e*B.BLOCK_LAYER_STEP;return t>=B.BLOCK_LAYER_MAX?B.BLOCK_LAYER_MAX:t}function Ye(e,t){const n=Math.min(Math.max(0,t),B.BLOCK_LAYER_STEP-1);return e+n}function yo(){return Math.floor((B.BLOCK_LAYER_MAX-B.BLOCK_LAYER_MIN)/B.BLOCK_LAYER_STEP)}const Tn=u.memo(({blockSizePx:e,borderStyle:t,blockZIndex:n,subZIndex:s=me.BORDER,visible:o=!0,dpi:a=W,className:i=""})=>{const l=u.useMemo(()=>{if(t)return new Ae(t)},[t]);if(!o||!l||!l.hasAnyBorder)return null;const c=Ye(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(Ie,{width:e.width,height:e.height,border:l,dpi:a})})}),Cn=u.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=me.BG,backgroundColor:s="transparent",className:o=""})=>{const a=Ye(t,n),i={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:s,pointerEvents:"none",zIndex:a};return r.jsx("div",{className:o,style:i,role:"presentation","aria-label":"Block background","data-testid":"block-canvas"})}),Rn={color:"#cccccc",width:{value:1,unit:"pt"},type:de.SOLID},dt={all:Rn},Mn=u.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=me.GUIDE,borderStyle:s=dt,visible:o=!0,dpi:a=W,className:i=""})=>{const l=u.useMemo(()=>{if(s)return new Ae(s)},[s]);if(!o||!l||!l.hasAnyBorder)return null;const c=Ye(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(Ie,{width:e.width,height:e.height,border:l,dpi:a})})}),Eo=({id:e,plugin:t,props:n,value:s,onChange:o,onBlur:a,readOnly:i,mode:l,blockSizePx:c,blockZIndex:d,subZIndex:m=me.CONTENT,validationState:x,className:g=""},b)=>{const j=u.useRef(null);u.useImperativeHandle(b,()=>({focus:()=>{var _;return(_=j.current)==null?void 0:_.focus()}}),[]);const y=Ye(d,m),f={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:a,readOnly:i,mode:l,dimensions:{widthPx:c.width,heightPx:c.height},validationState:x},h=t.Renderer;return r.jsx("div",{className:g,style:f,"data-testid":"block-renderer","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(h,{ref:j,...p})})},jo=u.forwardRef(Eo),He=u.memo(jo);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:a,onValueChange:i,onValueBlur:l,showGuides:c=!0,showBorder:d=!0,blockSubZIndex:m={bg:me.BG,guide:me.GUIDE,content:me.CONTENT,border:me.BORDER},defaultGuideBorder:x=dt,dpi:g=W,className:b="",pointerEvents:j="none"},y)=>{var h,_,I,E;const f=Bt(n,{zIndex:s,pointerEvents:j}),p=u.useMemo(()=>({width:n.width,height:n.height}),[n.width,n.height]);return r.jsxs("div",{style:f,"data-block-id":e.id,className:b,children:[r.jsx(Cn,{blockSizePx:p,blockZIndex:s,backgroundColor:(h=e.style)==null?void 0:h.backgroundColor,subZIndex:m.bg}),c&&!((_=e.style)!=null&&_.border)&&r.jsx(Mn,{blockSizePx:p,blockZIndex:s,subZIndex:m.guide,borderStyle:x,dpi:g}),r.jsx(He,{id:e.id,ref:y,plugin:t,props:e.props,value:a,onChange:i,onBlur:l,readOnly:o===ae.EDIT?((I=e.behavior)==null?void 0:I.readOnly)??!1:!0,mode:o,blockSizePx:p,blockZIndex:s,subZIndex:m.content}),r.jsx(Tn,{blockSizePx:p,blockZIndex:s,borderStyle:(E=e.style)==null?void 0:E.border,subZIndex:m.border,visible:d,dpi:g})]})}));Vt.displayName="BlockContainer";const Se=u.memo(({blocks:e,pluginRegistry:t,mode:n,values:s,selectedBlockIds:o=[],getBlockRectPx:a,onValueChange:i,onValueBlur:l,showGuides:c=!0,showBorder:d=!0,blockSubZIndex:m={bg:me.BG,guide:me.GUIDE,content:me.CONTENT,border:me.BORDER},defaultGuideBorder:x=dt,dpi:g=W,className:b=""})=>{const j=u.useRef(new Map),y={position:"absolute",inset:0,pointerEvents:"none"};return r.jsx("div",{className:b,style:y,"data-testid":"block-layer",children:e.map((f,p)=>{const h=t[f.kind];if(!h)return null;const _=a(f),I=o.includes(f.id);let E=$n(p);I&&(E=B.SELECT_BLOCK);const M=s[f.id]??f.initValue;return r.jsx(Vt,{ref:$=>{$?j.current.set(f.id,$):j.current.delete(f.id)},block:f,plugin:h,blockRectPx:_,blockZIndex:E,mode:n,value:M,onValueChange:i?$=>i(f.id,$):void 0,onValueBlur:$=>l==null?void 0:l(f.id,$),showGuides:c,showBorder:d,blockSubZIndex:m,defaultGuideBorder:x,dpi:g,pointerEvents:"none"},f.id)})})});Se.displayName="BlockLayer";const kn=u.memo(({contentPx:e,marginLeftPx:t,marginTopPx:n,borderStyle:s,visible:o=!0,dpi:a=W,zIndex:i=B.BORDER_OVERLAY,className:l=""})=>{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:l,style:d,"data-testid":"border-overlay",children:r.jsx(Ie,{width:e.width,height:e.height,border:c,dpi:a})})}),Pn=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 a={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:a,role:"presentation","aria-label":"Paper background","data-testid":"grid-canvas"})}),No="_label_fluf5_1",Io={label:No},Do="_editor_1aiew_9",$o="_input_1aiew_35",To="_select_1aiew_75",Co="_button_1aiew_107",Je={editor:Do,input:$o,select:To,button:Co};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(ne(s,"Dimension value"),!t.includes(o))throw new Error(`Unit not allowed: ${o}`);return{value:s,unit:o}}function Ro(e,t){return e.map(n=>An(n,t))}const Mo=10,ko=25.4,Po=.352778,Ao=.264583,Y={fromCm(e){return ne(e,"Centimeter value"),e*Mo},fromInch(e){return ne(e,"Inch value"),e*ko},fromPt(e){return ne(e,"Point value"),e*Po},fromPx(e){return ne(e,"Pixel value"),e*Ao},fromDim(e){switch(ne(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 Sn(e){return ne(e.value,"Dimension"),`${e.value}${e.unit}`}function So(e){return e.map(Sn)}const Lo=["fr","px","mm","cm","pt","inch"];function Oo(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 Ln=u.memo(({direction:e,dimension:t,currentPxSize:n,position:s,marginLeftPx:o,marginTopPx:a,onChange:i,onCancel:l})=>{const[c,d]=u.useState(t.value.toString()),[m,x]=u.useState(t.unit),g=u.useRef(null),b=u.useRef(null),j=e==="column"?{left:`${o+s}px`,top:`${a+24}px`,transform:"translateX(-50%)"}:{left:`${o+24}px`,top:`${a+s}px`,transform:"translateY(-50%)"};u.useEffect(()=>{var h,_;(h=g.current)==null||h.focus(),(_=g.current)==null||_.select()},[]),u.useEffect(()=>{const h=_=>{b.current&&!b.current.contains(_.target)&&l()};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[l]);const y=()=>{const h=Number.parseFloat(c);!Number.isNaN(h)&&h>=.1?i({unit:m,value:h}):l()},f=h=>{h.key==="Enter"?(h.preventDefault(),y()):h.key==="Escape"&&(h.preventDefault(),l())},p=h=>{const _=h.target.value;x(_);const I=Oo(n,_);d(I.toString())};return r.jsxs("div",{ref:b,className:Je.editor,style:j,"data-testid":`grid-unit-editor-${e}`,children:[r.jsx("input",{ref:g,type:"number",className:Je.input,value:c,onChange:h=>d(h.target.value),onKeyDown:f,min:"0.1",step:m==="fr"?"0.1":"1"}),r.jsx("select",{className:Je.select,value:m,onChange:p,children:Lo.map(h=>r.jsx("option",{value:h,children:h},h))}),r.jsx("button",{type:"button",className:Je.button,onClick:y,title:"確定",children:"✓"})]})});Ln.displayName="GridUnitEditor";function Go(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 tt=u.memo(({direction:e,index:t,dimension:n,position:s,currentPxSize:o,marginLeftPx:a,marginTopPx:i,isNearCursor:l,resizingPxSize:c,onDimensionChange:d})=>{const[m,x]=u.useState(!1);if(!l&&!m)return null;const g=e==="column"?{left:`${a+s}px`,top:`${i-20}px`,transform:"translateX(-50%)"}:{left:`${a-20}px`,top:`${i+s}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},b=()=>{x(!0)},j=h=>{d==null||d(e,t,h),x(!1)},y=()=>{x(!1)},p=c?(()=>{const h=Go(c,n.unit,n.value,o);return n.unit==="fr"?`${h}fr`:`${h}${n.unit}`})():(h=>h.unit==="fr"?`${h.value}fr`:`${h.value}${h.unit}`)(n);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:Io.label,style:g,onDoubleClick:b,"data-testid":`grid-dimension-${e}-${t}`,"aria-label":`グリッド寸法: ${p}`,children:p})," ",m&&r.jsx(Ln,{direction:e,dimension:n,currentPxSize:o,position:s,marginLeftPx:a,marginTopPx:i,onChange:j,onCancel:y})]})});tt.displayName="GridDimensionLabel";function Bo(e,t,n,s){let o="";for(const a of e)o+=`M ${a} 0 L ${a} ${s} `;for(const a of t)o+=`M 0 ${a} L ${n} ${a} `;return o}const On=u.memo(({gridPosPx:e,contentPx:t,marginLeftPx:n,marginTopPx:s,lineStyle:o,visible:a=!0,zIndex:i=B.GRID_OVERLAY,dpi:l=W,className:c=""})=>{const d=u.useMemo(()=>Bo(e.cols.slice(1,-1),e.rows.slice(1,-1),t.width,t.height),[e,t]);if(!a||!o)return null;const m=ke(o),x=V.fromDim(o.width,l),g={position:"absolute",left:`${n}px`,top:`${s}px`,pointerEvents:"none",zIndex:i};return r.jsx("svg",{className:c,style:g,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:m,fill:"none"})})}),Vo="_handle_c4kku_1",Uo="_dragging_c4kku_37",_t={handle:Vo,dragging:Uo},nt=u.memo(({direction:e,index:t,position:n,marginLeftPx:s,marginTopPx:o,onResizeStart:a,onResize:i,onResizeEnd:l})=>{const[c,d]=u.useState(!1),m=12,x=m/2,g=e==="column"?{left:`${s+n-x}px`,top:`${o-x}px`,width:`${m}px`,height:`${m}px`,cursor:"col-resize"}:{left:`${s-x}px`,top:`${o+n-x}px`,width:`${m}px`,height:`${m}px`,cursor:"row-resize"},b=u.useCallback(j=>{j.stopPropagation(),j.preventDefault();const y=e==="column"?j.clientX:j.clientY;d(!0),a==null||a(e,t);const f=h=>{const I=(e==="column"?h.clientX:h.clientY)-y;i==null||i(e,t,I)},p=h=>{const I=(e==="column"?h.clientX:h.clientY)-y;d(!1),l==null||l(e,t,I),window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",p)};window.addEventListener("pointermove",f),window.addEventListener("pointerup",p)},[e,t,a,i,l]);return r.jsx("div",{className:`${_t.handle} ${_t[e]} ${c?_t.dragging:""}`,style:g,onPointerDown:b,"data-testid":`grid-resize-handle-${e}-${t}`})});nt.displayName="GridResizeHandle";const Gn=u.memo(({paperPx:e,visible:t=!0,marginColor:n,zIndex:s=B.MARGIN_OVERLAY,className:o=""})=>{if(!t)return null;const a={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:a,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`}})]})}),mt=u.memo(({paperPx:e,gridPosPxs:t,gridDimensions:n,gridLineStyle:s,borderStyle:o,backgroundColor:a="#ffffff",boxShadow:i="0 2px 8px rgba(0, 0, 0, 0.1)",marginFillColor:l="rgba(0, 0, 0, 0.05)",showGridLines:c=!0,showMargins:d=!0,showBorder:m=!0,showResizeHandles:x=!1,showDimensionLabels:g=!1,onGridResize:b,onDimensionChange:j,className:y="",zIndex:f={}})=>{const[p,h]=u.useState(null),[_,I]=u.useState(null),[E,M]=u.useState(null),$=u.useRef(null);u.useEffect(()=>{const N=P=>{if(!$.current)return;const S=$.current.getBoundingClientRect();M({x:P.clientX-S.left,y:P.clientY-S.top})},D=P=>{if(!$.current)return;const S=$.current.getBoundingClientRect();(P.clientX<S.left||P.clientX>S.right||P.clientY<S.top||P.clientY>S.bottom)&&M(null)};return window.addEventListener("mousemove",N),window.addEventListener("mouseleave",D),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseleave",D)}},[]);const w=u.useMemo(()=>{if(!E)return!1;const N=e.content.width,D=e.content.height,P=e.margin.left,S=e.margin.top;return!(E.x>=P&&E.x<=P+N&&E.y>=S&&E.y<=S+D)},[E,e]),T=u.useCallback((N,D)=>{I({direction:N,index:D})},[]),k=u.useMemo(()=>{if(!p||!_)return null;const N=_.direction==="column"?t.cols:t.rows,D=_.index,P=N[D-1],S=p.position,F=P!==void 0?S-P:0,K=p.position,X=N[D+1],v=X!==void 0?X-K:0;return{direction:_.direction,prevIndex:D-1,prevSize:F,nextIndex:D,nextSize:v}},[p,_,t]),O=u.useCallback((N,D,P)=>{const S=N==="column"?t.cols:t.rows,F=S[D];if(F===void 0)return;const K=S[D-1],X=S[D+1],v=10;let C=P;if(K!==void 0){const A=K+v-F;C=Math.max(C,A)}if(X!==void 0){const A=X-v-F;C=Math.min(C,A)}h({direction:N,position:F+C})},[t]),R=u.useCallback((N,D,P)=>{const S=N==="column"?t.cols:t.rows,F=S[D];if(F===void 0){h(null);return}const K=S[D-1],X=S[D+1],v=10;let C=P;if(K!==void 0){const A=K+v-F;C=Math.max(C,A)}if(X!==void 0){const A=X-v-F;C=Math.min(C,A)}h(null),I(null),b==null||b(N,D,C)},[t,b]),L={position:"relative",width:"100%",height:"100%"};return r.jsxs("div",{ref:$,className:y,style:L,children:[r.jsx(Pn,{canvasPx:e.canvas,backgroundColor:a,boxShadow:i,zIndex:(f==null?void 0:f.canvas)??B.GRID_CANVAS,className:y}),d&&r.jsx(Gn,{paperPx:e,visible:d,marginColor:l,zIndex:(f==null?void 0:f.margin)??B.MARGIN_OVERLAY,className:y}),c&&r.jsx(On,{gridPosPx:t,contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,lineStyle:s,visible:c,zIndex:(f==null?void 0:f.grid)??B.GRID_OVERLAY,dpi:W,className:y}),m&&r.jsx(kn,{contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,borderStyle:o,visible:m,dpi:W,zIndex:(f==null?void 0:f.border)??B.BORDER_OVERLAY,className:y}),x&&b&&r.jsxs(r.Fragment,{children:[t.cols.map((N,D)=>{if(D===0||D===t.cols.length-1)return null;const P=`col-${D}`;return r.jsx(nt,{direction:"column",index:D,position:N,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:T,onResize:O,onResizeEnd:R},P)}),t.rows.map((N,D)=>{if(D===0||D===t.rows.length-1)return null;const P=`row-${D}`;return r.jsx(nt,{direction:"row",index:D,position:N,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:T,onResize:O,onResizeEnd:R},P)})]}),g&&n&&r.jsxs(r.Fragment,{children:[n.cols.map((N,D)=>{const P=t.cols[D],S=t.cols[D+1];if(P===void 0||S===void 0)return null;const F=(_==null?void 0:_.direction)==="column"&&(_.index===D||_.index===D+1);let K;k&&k.direction==="column"&&(k.prevIndex===D?K=k.prevSize:k.nextIndex===D&&(K=k.nextSize));const X=(P+S)/2,v=S-P,C=`col-dim-${D}`;return r.jsx(tt,{direction:"column",index:D,dimension:N,position:X,currentPxSize:v,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:w||F,resizingPxSize:K,onDimensionChange:j},C)})," ",n.rows.map((N,D)=>{const P=t.rows[D],S=t.rows[D+1];if(P===void 0||S===void 0)return null;const F=(_==null?void 0:_.direction)==="row"&&(_.index===D||_.index===D+1),K=(P+S)/2,X=S-P,v=`row-dim-${D}`;return r.jsx(tt,{direction:"row",index:D,dimension:N,position:K,currentPxSize:X,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:w||F,onDimensionChange:j},v)})]}),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 Fo{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 ze=new Fo;function jt(e,t,n,s){if(t<0||t>=e.length)return e;const o=[...e],a=o[t],i=o[t+1];return!a||!i?e:a.unit==="fr"&&i.unit==="fr"?zo(o,t,n,s):a.unit!=="fr"&&i.unit!=="fr"?Wo(o,t,n):a.unit==="fr"&&i.unit!=="fr"?dn(o,t,n,"next",s):dn(o,t,n,"current",s)}function zo(e,t,n,s){const o=e[t],a=e[t+1];if(!o||!a)return e;const i=e.reduce((j,y)=>y.unit==="fr"?j+y.value:j,0),l=s/i,c=o.value*l,d=a.value*l,m=Math.max(10,c+n),x=Math.max(10,d-n),g=m/l,b=x/l;return e[t]={...o,value:Math.round(g*100)/100},e[t+1]={...a,value:Math.round(b*100)/100},e}function Wo(e,t,n){const s=e[t],o=e[t+1];if(!s||!o)return e;const a=V.fromDim(s),i=V.fromDim(o),l=Math.max(10,a+n),c=Math.max(10,i-n);return e[t]={...s,value:rt(l,s.unit)},e[t+1]={...o,value:rt(c,o.unit)},e}function dn(e,t,n,s,o){const a=e[t],i=e[t+1];if(!a||!i)return e;let l=0,c=0;for(const x of e)x.unit==="fr"?l+=x.value:c+=V.fromDim(x);const d=o-c,m=l>0?d/l:0;if(s==="next"){const x=V.fromDim(i),g=Math.max(10,x-n);e[t+1]={...i,value:rt(g,i.unit)};const b=g-x,j=d-b,y=a.value*m,f=Math.max(10,y+n),p=l>0?f/j*l:1;e[t]={...a,value:Math.round(p*100)/100}}else{const x=V.fromDim(a),g=Math.max(10,x+n);e[t]={...a,value:rt(g,a.unit)};const b=g-x,j=d-b,y=i.value*m,f=Math.max(10,y-n),p=l>0?f/j*l: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 Bn(e){if(e.length===0)return[];const t=[];let n=0;for(const s of e){ne(s,"Pixel value");const o=s+n,a=Math.round(o);t.push(a),n=o-a}return t}const Yo=8,Ho=32,Ko=64,Xo=512,mn=(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=mn(Math.ceil(Math.log2(t+1)),Yo,Ho),a=mn(s*2,Ko,Xo);return{step:o,windowPx:a}}function et(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 a=s+o>>>1,i=t[a];if(i===void 0){o=a-1;continue}i<=e?s=a+1:o=a-1}return s-1}function It(e,t,n){const s=e.length-1;let o=0;return a=>{if(s<=0||e[0]===void 0||a<e[0]||e[s]===void 0)return-1;if(a>=e[s])return s-1;const i=e[o],l=e[o+1];if(i===void 0||l===void 0)return-1;if(i<=a&&a<l)return o;const c=i-n,d=l+n;if(a<c||a>=d)return o=et(a,e),o;let m=0;const x=e[o+1];if(x!==void 0&&a>=x)for(;o+1<s;){const g=e[o+1];if(g===void 0||a<g)break;if(o++,++m>t)return o=et(a,e),o}else for(;o>0;){const g=e[o];if(g===void 0||a>=g)break;if(o--,++m>t)return o=et(a,e),o}return o}}function ot(e,t){if(e.length===0)return[];ne(t,"Content size");let n=0,s=0;const o=e.map(l=>{if(ne(l.value,"Grid dimension value"),l.unit==="fr")return n+=l.value,null;{const c=Y.fromDim(l);return s+=c,c}});if(n===0)return jn(s,0,t,"Total fixed size"),o;const a=t-s;ne(a,"Content size - fixed sizes");const i=a/n;return o.map((l,c)=>{const d=e[c];if(l!=null)return l;if(!d)throw new Error(`dims[${c}] is undefined`);return d.value*i})}function st(e,t=96){ct(t,"DPI"),ut(t,"DPI");const n=e.map(o=>V.fromMm(o,t));return Bn(n)}function Zo(e,t,n){if(e.length===0)return[];ct(n,"DPI"),ut(n,"DPI"),ne(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 qo(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 Vn(e){e!=null&&e.title&&(document.title=e.title),e!=null&&e.removeScrollbars&&(document.body.style.overflow="hidden")}function Un(e){e!=null&&e.restoreScrollbars&&(document.body.style.overflow="")}function Dt(e,t){var o,a;const n=document.title,s=document.createElement("style");s.id="tatamicks-print-style",s.textContent=`
|
|
22
|
+
<%s key={someKey} {...props} />`,z,q,ut,q),F[q+z]=!0)}if(q=null,P!==void 0&&(n(P),q=""+P),a(M)&&(n(M.key),q=""+M.key),"key"in M){P={};for(var bt in M)bt!=="key"&&(P[bt]=M[bt])}else P=M;return q&&l(P,typeof b=="function"?b.displayName||b.name||"Unknown":b),m(b,q,P,s(),ht,Ot)}function f(b){v(b)?b._store&&(b._store.validated=1):typeof b=="object"&&b!==null&&b.$$typeof===L&&(b._payload.status==="fulfilled"?v(b._payload.value)&&b._payload.value._store&&(b._payload.value._store.validated=1):b._store&&(b._store.validated=1))}function v(b){return typeof b=="object"&&b!==null&&b.$$typeof===E}var g=u,E=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),N=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),D=Symbol.for("react.client.reference"),k=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,C=Object.prototype.hasOwnProperty,j=Array.isArray,_=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(b){return b()}};var R,T={},O=g.react_stack_bottom_frame.bind(g,i)(),U=_(o(i)),F={};Bt.Fragment=p,Bt.jsx=function(b,M,P){var z=1e4>k.recentlyCreatedOwnerStacks++;return d(b,M,P,!1,z?Error("react-stack-top-frame"):O,z?_(o(b)):U)},Bt.jsxs=function(b,M,P){var z=1e4>k.recentlyCreatedOwnerStacks++;return d(b,M,P,!0,z?Error("react-stack-top-frame"):O,z?_(o(b)):U)}})()),Bt}var dn;function Er(){return dn||(dn=1,process.env.NODE_ENV==="production"?Zt.exports=_r():Zt.exports=yr()),Zt.exports}var r=Er(),Tt=(t=>(t.left="flex-start",t.center="center",t.right="flex-end",t))(Tt||{}),Rt=(t=>(t.top="flex-start",t.center="center",t.bottom="flex-end",t))(Rt||{});const jr="_container_1mr3i_5",Nr="_select_1mr3i_11",Ir="_placeholderOverlay_1mr3i_44",ve={container:jr,select:Nr,placeholderOverlay:Ir},wt=t=>{const{value:e,onChange:n,readOnly:o=!1,config:s}=t,i=t.options??(s==null?void 0:s.options)??[],a=t.placeholder??(s==null?void 0:s.placeholder)??"選択してください",l=t.width??(s==null?void 0:s.width),c=t.height??(s==null?void 0:s.height),m=u.useCallback(E=>{const y=E.target.value;if(y==="")n(void 0);else{const p=i.find(x=>String(x.value)===y);n(p?p.value:y)}},[n,i]),d=e??"",f=e!==void 0&&e!=="",v={};l!==void 0?v.width=`${l}px`:v.width="100%";const g={width:"100%",height:c?`${c}px`:void 0};return r.jsxs("div",{className:ve.container,style:v,children:[!f&&r.jsx("input",{className:ve.placeholderOverlay,style:g,readOnly:!0,placeholder:a}),r.jsx("select",{className:ve.select,style:g,value:d,onChange:m,disabled:o,children:i.map(E=>r.jsx("option",{value:String(E.value),children:E.label},String(E.value)))})]})};wt.displayName="Select";const pn={justifyContent:{defaultValue:Tt.left,label:"水平方向の配置",group:"配置",description:"ブロック内のコンテンツの水平方向の配置を設定します。",Component:wt,config:{options:[{label:"左揃え",value:Tt.left},{label:"中央揃え",value:Tt.center},{label:"右揃え",value:Tt.right}]}},alignItems:{defaultValue:Rt.center,label:"垂直方向の配置",group:"配置",description:"ブロック内のコンテンツの垂直方向の配置を設定します。",Component:wt,config:{options:[{label:"上揃え",value:Rt.top},{label:"中央揃え",value:Rt.center},{label:"下揃え",value:Rt.bottom}]}}},Dr="_container_1tnp6_5",$r="_input_1tnp6_13",Tr="_label_1tnp6_29",be={container:Dr,input:$r,label:Tr},xt=({value:t,onChange:e,readOnly:n=!1,label:o,config:s})=>{const i=o??(s==null?void 0:s.label),a=u.useCallback(l=>{e(l.target.checked)},[e]);return r.jsxs("label",{className:be.container,children:[r.jsx("input",{type:"checkbox",className:be.input,checked:!!t,onChange:a,disabled:n}),i&&r.jsx("span",{className:be.label,children:i})]})};xt.displayName="Checkbox";const Rr="_container_qbvob_5",Mr="_colorButton_qbvob_13",Cr="_textInputWrapper_qbvob_40",Pr="_textInputPrefix_qbvob_62",Ar="_textInput_qbvob_40",kr="_popover_qbvob_125",Sr="_palette_qbvob_141",Lr="_paletteButton_qbvob_148",Or="_selected_qbvob_171",Gr="_transparentPaletteButton_qbvob_177",Br="_rgbaInputs_qbvob_183",Vr="_rgbaInputGroup_qbvob_190",Ur="_rgbaLabel_qbvob_205",tt={container:Rr,colorButton:Mr,textInputWrapper:Cr,textInputPrefix:Pr,textInput:Ar,popover:kr,palette:Sr,paletteButton:Lr,selected:Or,transparentPaletteButton:Gr,rgbaInputs:Br,rgbaInputGroup:Vr,rgbaLabel:Ur};function Ee(t){if(!t)return null;const e=t.match(/^#([0-9a-f]{6}|[0-9a-f]{8})$/i);if(e&&typeof e[1]=="string"){const o=e[1],s=Number.parseInt(o.slice(0,2),16),i=Number.parseInt(o.slice(2,4),16),a=Number.parseInt(o.slice(4,6),16),l=o.length===8?Number.parseInt(o.slice(6,8),16)/255:1;return{r:s,g:i,b:a,a:l}}const n=t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){const o=Number.parseInt(n[1]??"",10),s=Number.parseInt(n[2]??"",10),i=Number.parseInt(n[3]??"",10),a=n[4]?Number.parseFloat(n[4]):1;return{r:o,g:s,b:i,a}}return null}function xn(t){const{r:e,g:n,b:o,a:s}=t;if(s===0)return;const i=e.toString(16).padStart(2,"0"),a=n.toString(16).padStart(2,"0"),l=o.toString(16).padStart(2,"0");if(s<1){const c=Math.round(s*255).toString(16).padStart(2,"0");return`#${i}${a}${l}${c}`}return`#${i}${a}${l}`}function Fr(t){const{r:e,g:n,b:o,a:s}=t;if(s!==0)return`rgba(${e}, ${n}, ${o}, ${s})`}function zr(t){return/^#([0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}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"}],Ae=({onColorSelect:t,selectedColor:e,readOnly:n=!1})=>r.jsx("div",{className:tt.palette,children:vn.map((o,s)=>{const i=o.value===void 0,a=o.value===e,l=i?{}:{backgroundColor:o.value};return r.jsx("button",{type:"button",className:`${tt.paletteButton} ${i?tt.transparentPaletteButton:""} ${a?tt.selected:""}`,onClick:()=>t(o.value),disabled:n,title:o.label,"aria-label":o.label,style:l},o.value??`undefined-${s}`)})});Ae.displayName="ColorPalette";const Wr="_input_14n56_5",Yr={input:Wr},st=({value:t,onChange:e,readOnly:n=!1,min:o,max:s,step:i,integer:a,placeholder:l,width:c,height:m,config:d,onBlur:f})=>{const v=o??(d==null?void 0:d.min)??1,g=s??(d==null?void 0:d.max),E=i??(d==null?void 0:d.step)??1,y=a??(d==null?void 0:d.integer)??!1,p=l??(d==null?void 0:d.placeholder),x=c??(d==null?void 0:d.width),h=m??(d==null?void 0:d.height),w=u.useCallback(I=>{const B=I.target.value;if(B===""){e(void 0);return}let $=Number.parseFloat(B);Number.isNaN($)||(y&&($=Math.round($)),v!==void 0&&$<v&&($=v),g!==void 0&&$>g&&($=g),e($))},[e,v,g,y]),N={};return x!==void 0&&(N.width=`${x}px`),h!==void 0&&(N.height=`${h}px`,N.paddingTop=0,N.paddingBottom=0),r.jsx("input",{type:"number",className:Yr.input,style:N,value:t??"",onChange:w,onBlur:f,disabled:n,min:v,max:g,step:E,placeholder:p})};st.displayName="NumberInput";const ke=({rgba:t,onChange:e,readOnly:n=!1})=>r.jsxs("div",{className:tt.rgbaInputs,children:[r.jsxs("div",{className:tt.rgbaInputGroup,children:[r.jsx("span",{className:tt.rgbaLabel,children:"R"}),r.jsx(st,{value:t.r,onChange:o=>e("r",o),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:tt.rgbaInputGroup,children:[r.jsx("span",{className:tt.rgbaLabel,children:"G"}),r.jsx(st,{value:t.g,onChange:o=>e("g",o),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:tt.rgbaInputGroup,children:[r.jsx("span",{className:tt.rgbaLabel,children:"B"}),r.jsx(st,{value:t.b,onChange:o=>e("b",o),min:0,max:255,step:1,integer:!0,width:48,readOnly:n})]}),r.jsxs("div",{className:tt.rgbaInputGroup,children:[r.jsx("span",{className:tt.rgbaLabel,children:"A"}),r.jsx(st,{value:Math.round(t.a*100),onChange:o=>e("a",o!==void 0?o/100:void 0),min:0,max:100,step:1,integer:!0,width:48,readOnly:n})]})]});ke.displayName="RGBAInputs";const G={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},mt={BG:10,CONTENT:50,GUIDE:70,BORDER:80},Se=({isOpen:t,onClose:e,rgba:n,onRgbaChange:o,onColorSelect:s,selectedColor:i,readOnly:a=!1})=>{const l=u.useRef(null);return u.useEffect(()=>{if(!t)return;const c=m=>{l.current&&!l.current.contains(m.target)&&e()};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[t,e]),t?r.jsxs("div",{className:tt.popover,ref:l,style:{zIndex:G.DROPDOWN},children:[r.jsx(Ae,{onColorSelect:s,selectedColor:i,readOnly:a}),r.jsx(ke,{rgba:n,onChange:o,readOnly:a})]}):null};Se.displayName="ColorPickerPopover";const Wt=({value:t,onChange:e,readOnly:n=!1,showTextInput:o=!0,allowUndefined:s,placeholder:i,width:a,height:l,config:c})=>{const m=s??(c==null?void 0:c.allowUndefined)??!0,d=i??(m?"未設定":"#000000"),f=a??(c==null?void 0:c.width),v=l??(c==null?void 0:c.height),[g,E]=u.useState(!1),y=u.useRef(null),[p,x]=u.useState(()=>Ee(t)??{r:0,g:0,b:0,a:1});u.useEffect(()=>{const j=Ee(t);j&&x(j)},[t]);const h=u.useCallback(()=>{n||E(j=>!j)},[n]),[w,N]=u.useState(t?t.replace(/^#/,""):"");u.useEffect(()=>{N(t?t.replace(/^#/,""):"")},[t]);const I=u.useCallback(j=>{const _=j.target.value;/^[0-9A-Fa-f]*$/.test(_)&&N(_)},[]),B=u.useCallback(j=>{if(j===""&&m){e(void 0);return}/^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(j)?e(`#${j}`):N(t?t.replace(/^#/,""):"")},[e,m,t]),$=u.useCallback(j=>{B(j.target.value)},[B]),A=u.useCallback(j=>{j.key==="Enter"&&(j.preventDefault(),B(j.currentTarget.value),j.currentTarget.blur())},[B]),L=u.useCallback(j=>{e(j)},[e]),S=u.useCallback((j,_)=>{if(_===void 0)return;const R={...p,[j]:_};x(R),e(xn(R))},[p,e]),D=t??"未設定",k={};t&&(k.background=t);const C={};return f!==void 0?C.width=`${f}px`:C.width="100%",v!==void 0&&(C.height=`${v}px`),r.jsxs("div",{className:tt.container,style:C,ref:y,children:[r.jsx("button",{type:"button",className:tt.colorButton,onClick:h,disabled:n,title:D,"aria-label":"カラーピッカーを開く",style:k}),o&&r.jsxs("div",{className:tt.textInputWrapper,children:[r.jsx("span",{className:tt.textInputPrefix,children:"#"}),r.jsx("input",{type:"text",className:tt.textInput,value:w,onChange:I,onKeyDown:A,onBlur:$,disabled:n,placeholder:d,maxLength:8})]}),r.jsx(Se,{isOpen:g,onClose:()=>E(!1),rgba:p,onRgbaChange:S,onColorSelect:L,selectedColor:t,readOnly:n})]})};Wt.displayName="ColorPicker";const Hr="_container_1n9lj_5",Xr="_valueInput_1n9lj_23",qr="_unitSelect_1n9lj_45",ge={container:Hr,valueInput:Xr,unitSelect:qr},rt=t=>{const{value:e,onChange:n,readOnly:o=!1,config:s}=t,i=t.allowedUnits??(s==null?void 0:s.allowedUnits),a=t.min??(s==null?void 0:s.min),l=t.max??(s==null?void 0:s.max),c=t.step??(s==null?void 0:s.step)??1,m=t.placeholder??(s==null?void 0:s.placeholder),d=t.width??(s==null?void 0:s.width),f=t.height??(s==null?void 0:s.height),v=(e==null?void 0:e.unit)??(i==null?void 0:i[0]),g=u.useCallback(w=>{const N=w.target.value;let I=Number.parseFloat(N);if(Number.isNaN(I))return;const B=a??1;I<B&&(I=B),l!==void 0&&I>l&&(I=l),n({value:I,unit:(e==null?void 0:e.unit)??v})},[e,n,v,a,l]),E=u.useCallback(w=>{const N=w.target.value;if(N==="")return;let I=Number.parseFloat(N);if(Number.isNaN(I))return;const B=a??1;I<B&&(I=B,n({value:I,unit:(e==null?void 0:e.unit)??v})),l!==void 0&&I>l&&(I=l,n({value:I,unit:(e==null?void 0:e.unit)??v}))},[e,n,v,a,l]),y=u.useCallback(w=>{const N=w.target.value;n({value:(e==null?void 0:e.value)??1,unit:N})},[e,n]),p=(e==null?void 0:e.value)??"",x=(e==null?void 0:e.unit)??v??"",h={};return d!==void 0?h.width=`${d}px`:h.width="100%",f!==void 0&&(h.height=`${f}px`),r.jsxs("div",{className:ge.container,style:h,children:[r.jsx("input",{type:"number",className:ge.valueInput,value:p,onChange:g,onBlur:E,placeholder:m,min:a??1,max:l,step:c,readOnly:o,disabled:o}),r.jsx("select",{className:ge.unitSelect,value:x,onChange:y,disabled:o||!i||i.length<=1,children:i?i.map(w=>r.jsx("option",{value:w,children:w},w)):r.jsx("option",{value:x,children:x})})]})},Kr="_container_1bfk3_6",Zr="_scrollArea_1bfk3_23",Jr="_emptyState_1bfk3_31",we={container:Kr,scrollArea:Zr,emptyState:Jr},Le=({children:t,emptyMessage:e,className:n})=>r.jsx("div",{className:`${we.container} ${n||""}`,children:t?r.jsx("div",{className:we.scrollArea,children:t}):e&&r.jsx("div",{className:we.emptyState,children:e})}),Qr="_root_qs6t8_3",to="_list_qs6t8_11",eo="_trigger_qs6t8_26",no="_content_qs6t8_71",le={root:Qr,list:to,trigger:eo,content:no},ce=u.createContext(void 0),Oe=({defaultValue:t,value:e,onValueChange:n,children:o,variant:s="default",className:i=""})=>{const[a,l]=u.useState(t),c=e??a,m=d=>{l(d),n==null||n(d)};return r.jsx(ce.Provider,{value:{value:c,onChange:m,variant:s},children:r.jsx("div",{className:`${le.root} ${i}`,"data-variant":s,children:o})})},Ge=({children:t,className:e="",width:n,height:o,style:s})=>{const i=u.useContext(ce);if(!i)throw new Error("TabsList must be used within a Tabs component");const{variant:a}=i,l={...s};return n!==void 0&&(l.width=`${n}px`),o!==void 0&&(l.height=`${o}px`),r.jsx("div",{className:`${le.list} ${e}`,"data-variant":a,style:l,children:t})},yt=({value:t,children:e,className:n="",disabled:o=!1,width:s,height:i,style:a})=>{const l=u.useContext(ce);if(!l)throw new Error("TabsTrigger must be used within a Tabs component");const{value:c,onChange:m,variant:d}=l,f=c===t,v={...a};return s!==void 0&&(v.width=`${s}px`),i!==void 0&&(v.height=`${i}px`),r.jsx("button",{className:`${le.trigger} ${n}`,"data-state":f?"active":"inactive","data-variant":d,onClick:()=>m(t),disabled:o,type:"button",style:v,children:e})},Et=({value:t,children:e,className:n=""})=>{const o=u.useContext(ce);if(!o)throw new Error("TabsContent must be used within a Tabs component");const{value:s}=o;return s!==t?null:r.jsx("div",{className:`${le.content} ${n}`,children:e})},ro="_input_9unrj_5",oo={input:ro},At=({value:t,onChange:e,readOnly:n=!1,placeholder:o,maxLength:s,multiline:i,rows:a,width:l,height:c,config:m,onBlur:d})=>{const f=o??(m==null?void 0:m.placeholder),v=s??(m==null?void 0:m.maxLength),g=i??(m==null?void 0:m.multiline)??!1,E=a??(m==null?void 0:m.rows)??3,y=u.useCallback(h=>{const w=h.target.value;e(w)},[e]),p={};l!==void 0?p.width=`${l}px`:p.width="100%",c!==void 0&&(p.height=`${c}px`);const x={className:oo.input,style:p,value:t??"",onChange:y,disabled:n,placeholder:f,maxLength:v};return g?r.jsx("textarea",{...x,rows:E}):r.jsx("input",{...x,type:"text",onBlur:d})};At.displayName="TextInput";const so=["mm","cm","fr","inch","pt","px","%"],io=["mm","cm","pt","inch","px"],ao=["mm","cm","inch"],lo=["mm","cm","fr","inch","pt","px"],bn=["px","pt","mm"],gn=["px","pt","mm"],$t=["mm","pt","px","%"],je=["mm","cm","inch","pt","px","%"],wn={isIndividual:{defaultValue:!1,label:"個別に設定",group:"余白",Component:xt,description:"上下左右の余白を個別に設定します"},all:{defaultValue:{value:0,unit:"px"},label:"全方向",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>!t.isIndividual},top:{defaultValue:{value:0,unit:"px"},label:"上",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>t.isIndividual===!0},right:{defaultValue:{value:0,unit:"px"},label:"右",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>t.isIndividual===!0},bottom:{defaultValue:{value:0,unit:"px"},label:"下",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>t.isIndividual===!0},left:{defaultValue:{value:0,unit:"px"},label:"左",group:"余白",Component:rt,config:{allowedUnits:$t,min:0},condition:t=>t.isIndividual===!0}},co={...pn,...wn},_n=[{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"}],uo={fontSize:{defaultValue:{value:14,unit:"pt"},label:"フォントサイズ",group:"フォント",description:"テキストのフォントサイズを設定します",Component:rt,config:{allowedUnits:gn,min:1,step:1}},fontFamily:{defaultValue:"sans-serif",label:"フォント",group:"フォント",Component:wt,config:{placeholder:"フォントを選択",options:_n}},color:{defaultValue:void 0,label:"文字色",group:"フォント",Component:Wt,config:{allowUndefined:!0}},fontWeight:{defaultValue:!1,label:"太字",group:"フォント",description:"テキストを太字にします",Component:xt},italic:{defaultValue:!1,label:"斜体",group:"フォント",description:"テキストを斜体にします",Component:xt},underline:{defaultValue:!1,label:"下線",group:"フォント",description:"テキストに下線を引きます",Component:xt},lineThrough:{defaultValue:!1,label:"取り消し線",group:"フォント",description:"テキストに取り消し線を引きます",Component:xt},lineHeight:{defaultValue:1.2,label:"行の高さ",group:"フォント",description:"行の高さを設定します(1.0〜3.0)",Component:st,config:{min:1,max:3,step:.1}}};function mo(t){return t.reduce((e,n)=>(e[n.kind]=n,e),{})}var jt=(t=>(t.Contain="contain",t.Cover="cover",t.Fill="fill",t.None="none",t.ScaleDown="scale-down",t))(jt||{});const ho={objectFit:{defaultValue:jt.Contain,label:"表示方法",group:"画像",description:"画像のサイズが枠と合わない場合の表示方法を設定します",Component:wt,config:{options:[{label:"全体を表示",value:jt.Contain},{label:"枠を埋める/切り抜き",value:jt.Cover},{label:"引き伸ばす/縮小する",value:jt.Fill},{label:"元のサイズ",value:jt.None},{label:"縮小のみ",value:jt.ScaleDown}]}},alt:{defaultValue:"",label:"代替テキスト",group:"画像",description:"画像が表示できない場合に表示されるテキスト",Component:At,config:{placeholder:"画像の説明"}}};var Mt=(t=>(t.Normal="normal",t.BreakWord="break-word",t.BreakAll="break-all",t))(Mt||{}),Ct=(t=>(t.Normal="normal",t.NoWrap="nowrap",t.Pre="pre",t.PreWrap="pre-wrap",t.PreLine="pre-line",t))(Ct||{});const fo={multiline:{defaultValue:!1,label:"複数行モード",group:"設定",Component:xt,config:{label:"有効にする"}},wordWrap:{defaultValue:Mt.Normal,label:"単語の折り返し",group:"設定",Component:wt,config:{options:[{label:"通常",value:Mt.Normal},{label:"単語で改行",value:Mt.BreakWord},{label:"強制改行",value:Mt.BreakAll}]},condition:t=>t.multiline===!0},whiteSpace:{defaultValue:Ct.Normal,label:"空白文字の扱い",group:"設定",Component:wt,config:{options:[{label:"通常",value:Ct.Normal},{label:"折り返しなし",value:Ct.NoWrap},{label:"そのまま表示",value:Ct.Pre}]},condition:t=>t.multiline===!0}},po={placeholder:{defaultValue:void 0,label:"プレースホルダー",group:"設定",description:"入力欄に表示するプレースホルダーテキストを設定します",Component:At,config:{placeholder:"例: テキストを入力してください"}}},xo={width:{defaultValue:void 0,label:"幅",group:"サイズ",description:"要素の幅を設定します",Component:rt,config:{min:0,allowedUnits:je,placeholder:"auto"}},height:{defaultValue:void 0,label:"高さ",group:"サイズ",description:"要素の高さを設定します",Component:rt,config:{min:0,allowedUnits:je,placeholder:"auto"}}},yn=t=>{const e={};return Object.entries(t.properties).forEach(([n,o])=>{o!==!1&&typeof o=="object"&&o!==null&&"defaultValue"in o&&(e[n]=o.defaultValue)}),e};function En(t){const e=Date.now(),n=Math.random().toString(36).slice(2);return`${t}_${e}_${n}`}function Nt(t,e,n){const o=yn(t);return{id:En(t.kind),kind:t.kind,layout:{x:e.x,y:e.y,w:e.w,h:e.h},style:{},behavior:{},props:{...o,...n}}}const vo={required:{defaultValue:!1,label:"必須項目",group:"バリデーション",description:"この項目を必須入力にします",Component:xt,config:{label:"必須にする"}},minLength:{defaultValue:void 0,label:"最小文字数",group:"バリデーション",description:"入力可能な最小文字数を設定します",Component:st,config:{min:0,integer:!0,placeholder:"制限なし"}},maxLength:{defaultValue:void 0,label:"最大文字数",group:"バリデーション",description:"入力可能な最大文字数を設定します",Component:st,config:{min:0,integer:!0,placeholder:"制限なし"}},pattern:{defaultValue:void 0,label:"入力パターン (正規表現)",group:"バリデーション",description:"入力値を検証する正規表現パターンを設定します",Component:At,config:{placeholder:"例: ^[0-9]+$"},disableInMultiSelection:!0}};var ct=(t=>(t.ADD="add",t.UPDATE="update",t.DELETE="delete",t.MOVE="move",t.RESIZE="resize",t.DUPLICATE="duplicate",t.PASTE="paste",t))(ct||{});const jn={cols:Array.from({length:12}).map(()=>({value:1,unit:"fr"})),rows:Array.from({length:16}).map(()=>({value:1,unit:"fr"}))};var dt=(t=>(t.SOLID="solid",t.DASHED="dashed",t.DOTTED="dotted",t))(dt||{});const W=96;function ue(t,e){if(t<=0){const n=e??"Value";throw new Error(`${n} must be positive (> 0): got ${t}`)}}function et(t,e){if(t<0){const n=e??"Value";throw new Error(`${n} must be non-negative (>= 0): got ${t}`)}}function Nn(t,e,n,o){if(t<e||t>n){const s=o??"Value";throw new Error(`${s} must be between ${e} and ${n}: got ${t}`)}}function de(t,e){if(!Number.isInteger(t)){const n=e??"Value";throw new Error(`${n} must be an integer: got ${t}`)}}function bo(t,e){if(!Number.isFinite(t)){const n=e??"Value";throw new Error(`${n} must be a finite number: got ${t}`)}}const go=25.4,wo=2.54,_o=72,V={_assertDpi(t){ue(t,"DPI"),de(t,"DPI")},fromMm(t,e=W){return V._assertDpi(e),et(t,"Millimeter value"),t*e/go},fromCm(t,e=W){return V._assertDpi(e),et(t,"Centimeter value"),t*e/wo},fromInch(t,e=W){return V._assertDpi(e),et(t,"Inch value"),t*e},fromPt(t,e=W){return V._assertDpi(e),et(t,"Point value"),t*e/_o},fromPx(t,e=W){return V._assertDpi(e),et(t,"Pixel value"),t*e/W},fromDim(t,e=W,n){switch(V._assertDpi(e),et(t.value,"Dimension value"),t.unit){case"mm":return V.fromMm(t.value,e);case"cm":return V.fromCm(t.value,e);case"inch":return V.fromInch(t.value,e);case"pt":return V.fromPt(t.value,e);case"px":return V.fromPx(t.value,e);case"%":if(n===void 0)throw new Error("Base size must be defined for percentage values.");return t.value/100*n;case"fr":throw new Error(`Cannot convert ${t.unit} to px. Use physical units only.`);default:{const o=t.unit;throw new Error(`Unsupported unit: ${o}`)}}}},Pt=t=>{if(!(t!=null&&t.width)||!(t!=null&&t.type))return;const e=t.width.value;if(e!==0){if(t.type===dt.DASHED)return`${e*4} ${e*2}`;if(t.type===dt.DOTTED)return`${e*1} ${e*2}`}};class kt{constructor(e){this.style=e}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(e,n=W){const o=this.top;return o?{x1:0,y1:0,x2:e,y2:0,stroke:o.color,strokeWidth:V.fromDim(o.width,n),strokeDasharray:Pt(o),vectorEffect:"non-scaling-stroke","data-edge":"top"}:null}getRightSVGProps(e,n,o=W){const s=this.right;return s?{x1:e,y1:0,x2:e,y2:n,stroke:s.color,strokeWidth:V.fromDim(s.width,o),strokeDasharray:Pt(s),vectorEffect:"non-scaling-stroke","data-edge":"right"}:null}getBottomSVGProps(e,n,o=W){const s=this.bottom;return s?{x1:0,y1:n,x2:e,y2:n,stroke:s.color,strokeWidth:V.fromDim(s.width,o),strokeDasharray:Pt(s),vectorEffect:"non-scaling-stroke","data-edge":"bottom"}:null}getLeftSVGProps(e,n=W){const o=this.left;return o?{x1:0,y1:0,x2:0,y2:e,stroke:o.color,strokeWidth:V.fromDim(o.width,n),strokeDasharray:Pt(o),vectorEffect:"non-scaling-stroke","data-edge":"left"}:null}}var it=(t=>(t.FORM="Form",t.EDIT="Edit",t.VIEW="View",t))(it||{}),pt=(t=>(t.A4="A4",t.B5="B5",t.A3="A3",t.LETTER="Letter",t.LEGAL="Legal",t.CUSTOM="Custom",t))(pt||{});const Be={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:Be.A4,margin:In},yo={paper:Dn,grid:jn,blocks:[]};var $n=(t=>(t.ERROR="error",t.WARNING="warning",t.INFO="info",t))($n||{});const It=u.memo(({width:t,height:e,border:n,dpi:o=W,className:s=""})=>n.hasAnyBorder?r.jsxs("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",className:s,style:{overflow:"visible"},children:[r.jsx("title",{children:"border SVG"}),n.top&&r.jsx("line",{...n.getTopSVGProps(t,o)}),n.right&&r.jsx("line",{...n.getRightSVGProps(t,e,o)}),n.bottom&&r.jsx("line",{...n.getBottomSVGProps(t,e,o)}),n.left&&r.jsx("line",{...n.getLeftSVGProps(e,o)})]}):null);It.displayName="BorderRenderer";function Tn(t){const e=G.BLOCK_LAYER_MIN+t*G.BLOCK_LAYER_STEP;return e>=G.BLOCK_LAYER_MAX?G.BLOCK_LAYER_MAX:e}function Yt(t,e){const n=Math.min(Math.max(0,e),G.BLOCK_LAYER_STEP-1);return t+n}function Eo(){return Math.floor((G.BLOCK_LAYER_MAX-G.BLOCK_LAYER_MIN)/G.BLOCK_LAYER_STEP)}const Rn=u.memo(({blockSizePx:t,borderStyle:e,blockZIndex:n,subZIndex:o=mt.BORDER,visible:s=!0,dpi:i=W,className:a=""})=>{const l=u.useMemo(()=>{if(e)return new kt(e)},[e]);if(!s||!l||!l.hasAnyBorder)return null;const c=Yt(n,o),m={position:"absolute",left:0,top:0,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:a,style:m,"data-testid":"block-border",children:r.jsx(It,{width:t.width,height:t.height,border:l,dpi:i})})}),Mn=u.memo(({blockSizePx:t,blockZIndex:e,subZIndex:n=mt.BG,backgroundColor:o="transparent",className:s=""})=>{const i=Yt(e,n),a={position:"absolute",inset:0,width:`${t.width}px`,height:`${t.height}px`,backgroundColor:o,pointerEvents:"none",zIndex:i};return r.jsx("div",{className:s,style:a,role:"presentation","aria-label":"Block background","data-testid":"block-canvas"})}),Cn={color:"#cccccc",width:{value:1,unit:"pt"},type:dt.SOLID},me={all:Cn},Pn=u.memo(({blockSizePx:t,blockZIndex:e,subZIndex:n=mt.GUIDE,borderStyle:o=me,visible:s=!0,dpi:i=W,className:a=""})=>{const l=u.useMemo(()=>{if(o)return new kt(o)},[o]);if(!s||!l||!l.hasAnyBorder)return null;const c=Yt(e,n),m={position:"absolute",left:0,top:0,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none",overflow:"visible",zIndex:c};return r.jsx("div",{className:a,style:m,"data-testid":"block-base-border",children:r.jsx(It,{width:t.width,height:t.height,border:l,dpi:i})})}),jo=({id:t,plugin:e,props:n,value:o,onChange:s,onBlur:i,readOnly:a,mode:l,blockSizePx:c,blockZIndex:m,subZIndex:d=mt.CONTENT,validationState:f,className:v=""},g)=>{const E=u.useRef(null);u.useImperativeHandle(g,()=>({focus:()=>{var w;return(w=E.current)==null?void 0:w.focus()}}),[]);const y=Yt(m,d),p={position:"absolute",inset:0,width:`${c.width}px`,height:`${c.height}px`,zIndex:y,pointerEvents:"auto"},x={id:t,props:n,value:o,onChange:s??(()=>{}),onBlur:i,readOnly:a,mode:l,dimensions:{widthPx:c.width,heightPx:c.height},validationState:f},h=e.Renderer;return r.jsx("div",{className:v,style:p,"data-testid":"block-renderer","data-block-id":t,"data-plugin-kind":e.kind,children:r.jsx(h,{ref:E,...x})})},No=u.forwardRef(jo),Ht=u.memo(No);function Ve(t,e){return{position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,zIndex:e==null?void 0:e.zIndex,pointerEvents:(e==null?void 0:e.pointerEvents)??"auto"}}const Ue=u.memo(u.forwardRef(({block:t,plugin:e,blockRectPx:n,blockZIndex:o,mode:s,value:i,onValueChange:a,onValueBlur:l,showGuides:c=!0,showBorder:m=!0,blockSubZIndex:d={bg:mt.BG,guide:mt.GUIDE,content:mt.CONTENT,border:mt.BORDER},defaultGuideBorder:f=me,dpi:v=W,className:g="",pointerEvents:E="none"},y)=>{var h,w,N,I;const p=Ve(n,{zIndex:o,pointerEvents:E}),x=u.useMemo(()=>({width:n.width,height:n.height}),[n.width,n.height]);return r.jsxs("div",{style:p,"data-block-id":t.id,className:g,children:[r.jsx(Mn,{blockSizePx:x,blockZIndex:o,backgroundColor:(h=t.style)==null?void 0:h.backgroundColor,subZIndex:d.bg}),c&&!((w=t.style)!=null&&w.border)&&r.jsx(Pn,{blockSizePx:x,blockZIndex:o,subZIndex:d.guide,borderStyle:f,dpi:v}),r.jsx(Ht,{id:t.id,ref:y,plugin:e,props:t.props,value:i,onChange:a,onBlur:l,readOnly:s===it.EDIT?((N=t.behavior)==null?void 0:N.readOnly)??!1:!0,mode:s,blockSizePx:x,blockZIndex:o,subZIndex:d.content}),r.jsx(Rn,{blockSizePx:x,blockZIndex:o,borderStyle:(I=t.style)==null?void 0:I.border,subZIndex:d.border,visible:m,dpi:v})]})}));Ue.displayName="BlockContainer";const St=u.memo(({blocks:t,pluginRegistry:e,mode:n,values:o,selectedBlockIds:s=[],getBlockRectPx:i,onValueChange:a,onValueBlur:l,showGuides:c=!0,showBorder:m=!0,blockSubZIndex:d={bg:mt.BG,guide:mt.GUIDE,content:mt.CONTENT,border:mt.BORDER},defaultGuideBorder:f=me,dpi:v=W,className:g=""})=>{const E=u.useRef(new Map),y={position:"absolute",inset:0,pointerEvents:"none"};return r.jsx("div",{className:g,style:y,"data-testid":"block-layer",children:t.map((p,x)=>{const h=e[p.kind];if(!h)return null;const w=i(p),N=s.includes(p.id);let I=Tn(x);N&&(I=G.SELECT_BLOCK);const B=o[p.id]??p.initValue;return r.jsx(Ue,{ref:$=>{$?E.current.set(p.id,$):E.current.delete(p.id)},block:p,plugin:h,blockRectPx:w,blockZIndex:I,mode:n,value:B,onValueChange:a?$=>a(p.id,$):void 0,onValueBlur:$=>l==null?void 0:l(p.id,$),showGuides:c,showBorder:m,blockSubZIndex:d,defaultGuideBorder:f,dpi:v,pointerEvents:"none"},p.id)})})});St.displayName="BlockLayer";const An=u.memo(({contentPx:t,marginLeftPx:e,marginTopPx:n,borderStyle:o,visible:s=!0,dpi:i=W,zIndex:a=G.BORDER_OVERLAY,className:l=""})=>{const c=u.useMemo(()=>{if(o)return new kt(o)},[o]);if(!s||!c||!c.hasAnyBorder)return null;const m={position:"absolute",left:`${e}px`,top:`${n}px`,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none",overflow:"visible",zIndex:a};return r.jsx("div",{className:l,style:m,"data-testid":"border-overlay",children:r.jsx(It,{width:t.width,height:t.height,border:c,dpi:i})})}),kn=u.memo(({canvasPx:t,backgroundColor:e="#ffffff",boxShadow:n="0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:o=G.GRID_CANVAS,className:s})=>{const i={position:"absolute",inset:0,width:`${t.width}px`,height:`${t.height}px`,backgroundColor:e,boxShadow:n,pointerEvents:"none",zIndex:o};return r.jsx("div",{className:s,style:i,role:"presentation","aria-label":"Paper background","data-testid":"grid-canvas"})}),Io="_label_vgaic_1",Do={label:Io},$o="_editor_6szgo_5",To="_input_6szgo_18",Ro="_select_6szgo_38",Mo="_button_6szgo_54",Jt={editor:$o,input:To,select:Ro,button:Mo};function Sn(t,e){const n=t.match(/^(\d+(?:\.\d+)?)([a-zA-Z%]+)$/);if(!n)throw new Error(`Invalid dimension string: ${t}`);const o=Number(n[1]),s=n[2];if(et(o,"Dimension value"),!e.includes(s))throw new Error(`Unit not allowed: ${s}`);return{value:o,unit:s}}function Co(t,e){return t.map(n=>Sn(n,e))}const Po=10,Ao=25.4,ko=.352778,So=.264583,Y={fromCm(t){return et(t,"Centimeter value"),t*Po},fromInch(t){return et(t,"Inch value"),t*Ao},fromPt(t){return et(t,"Point value"),t*ko},fromPx(t){return et(t,"Pixel value"),t*So},fromDim(t){switch(et(t.value,"Dimension value"),t.unit){case"mm":return t.value;case"cm":return Y.fromCm(t.value);case"inch":return Y.fromInch(t.value);case"pt":return Y.fromPt(t.value);case"px":return Y.fromPx(t.value);case"fr":case"%":throw new Error(`Cannot convert ${t.unit} to mm. Use physical units only.`);default:{const e=t.unit;throw new Error(`Unsupported unit: ${e}`)}}}};function Ln(t){return et(t.value,"Dimension"),`${t.value}${t.unit}`}function Lo(t){return t.map(Ln)}const Oo=["fr","px","mm","cm","pt","inch"];function Go(t,e){if(e==="fr")return 1;switch(e){case"px":return t;case"mm":{const n=Y.fromPx(t);return Math.round(n*10)/10}case"cm":{const o=Y.fromPx(t)/10;return Math.round(o*100)/100}case"inch":{const o=Y.fromPx(t)/25.4;return Math.round(o*100)/100}case"pt":{const s=Y.fromPx(t)/25.4*72;return Math.round(s*10)/10}default:{const n=e;throw new Error(`Unsupported unit: ${n}`)}}}const On=u.memo(({direction:t,dimension:e,currentPxSize:n,position:o,marginLeftPx:s,marginTopPx:i,onChange:a,onCancel:l})=>{const[c,m]=u.useState(e.value.toString()),[d,f]=u.useState(e.unit),v=u.useRef(null),g=u.useRef(null),E=t==="column"?{left:`${s+o}px`,top:`${i+24}px`,transform:"translateX(-50%)"}:{left:`${s+24}px`,top:`${i+o}px`,transform:"translateY(-50%)"};u.useEffect(()=>{var h,w;(h=v.current)==null||h.focus(),(w=v.current)==null||w.select()},[]),u.useEffect(()=>{const h=w=>{g.current&&!g.current.contains(w.target)&&l()};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[l]);const y=()=>{const h=Number.parseFloat(c);!Number.isNaN(h)&&h>=.1?a({unit:d,value:h}):l()},p=h=>{h.key==="Enter"?(h.preventDefault(),y()):h.key==="Escape"&&(h.preventDefault(),l())},x=h=>{const w=h.target.value;f(w);const N=Go(n,w);m(N.toString())};return r.jsxs("div",{ref:g,className:Jt.editor,style:E,"data-testid":`grid-unit-editor-${t}`,children:[r.jsx("input",{ref:v,type:"number",className:Jt.input,value:c,onChange:h=>m(h.target.value),onKeyDown:p,min:"0.1",step:d==="fr"?"0.1":"1"}),r.jsx("select",{className:Jt.select,value:d,onChange:x,children:Oo.map(h=>r.jsx("option",{value:h,children:h},h))}),r.jsx("button",{type:"button",className:Jt.button,onClick:y,title:"確定",children:"✓"})]})});On.displayName="GridUnitEditor";function Bo(t,e,n,o){if(e==="fr"){if(n!==void 0&&o!==void 0&&o>0){const s=t/o;return Math.round(n*s*100)/100}return 1}switch(e){case"px":return Math.round(t);case"mm":{const s=Y.fromPx(t);return Math.round(s*10)/10}case"cm":{const s=Y.fromPx(t);return Math.round(s/10*100)/100}case"inch":{const s=Y.fromPx(t);return Math.round(s/25.4*100)/100}case"pt":{const s=Y.fromPx(t);return Math.round(s/25.4*72*10)/10}default:{const s=e;throw new Error(`Unsupported unit: ${s}`)}}}const ee=u.memo(({direction:t,index:e,dimension:n,position:o,currentPxSize:s,marginLeftPx:i,marginTopPx:a,isNearCursor:l,resizingPxSize:c,onDimensionChange:m})=>{const[d,f]=u.useState(!1);if(!l&&!d)return null;const v=t==="column"?{left:`${i+o}px`,top:`${a-20}px`,transform:"translateX(-50%)"}:{left:`${i-20}px`,top:`${a+o}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},g=()=>{f(!0)},E=h=>{m==null||m(t,e,h),f(!1)},y=()=>{f(!1)},x=c?(()=>{const h=Bo(c,n.unit,n.value,s);return n.unit==="fr"?`${h}fr`:`${h}${n.unit}`})():(h=>h.unit==="fr"?`${h.value}fr`:`${h.value}${h.unit}`)(n);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:Do.label,style:v,onDoubleClick:g,"data-testid":`grid-dimension-${t}-${e}`,"aria-label":`グリッド寸法: ${x}`,children:x})," ",d&&r.jsx(On,{direction:t,dimension:n,currentPxSize:s,position:o,marginLeftPx:i,marginTopPx:a,onChange:E,onCancel:y})]})});ee.displayName="GridDimensionLabel";function Vo(t,e,n,o){let s="";for(const i of t)s+=`M ${i} 0 L ${i} ${o} `;for(const i of e)s+=`M 0 ${i} L ${n} ${i} `;return s}const Gn=u.memo(({gridPosPx:t,contentPx:e,marginLeftPx:n,marginTopPx:o,lineStyle:s,visible:i=!0,zIndex:a=G.GRID_OVERLAY,dpi:l=W,className:c=""})=>{const m=u.useMemo(()=>Vo(t.cols.slice(1,-1),t.rows.slice(1,-1),e.width,e.height),[t,e]);if(!i||!s)return null;const d=Pt(s),f=V.fromDim(s.width,l),v={position:"absolute",left:`${n}px`,top:`${o}px`,pointerEvents:"none",zIndex:a};return r.jsx("svg",{className:c,style:v,width:e.width,height:e.height,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Grid overlay lines",children:r.jsx("path",{d:m,stroke:s.color,strokeWidth:f,strokeDasharray:d,fill:"none"})})}),Uo="_handle_1mgtx_1",Fo="_dragging_1mgtx_19",_e={handle:Uo,dragging:Fo},ne=u.memo(({direction:t,index:e,position:n,marginLeftPx:o,marginTopPx:s,onResizeStart:i,onResize:a,onResizeEnd:l})=>{const[c,m]=u.useState(!1),d=12,f=d/2,v=t==="column"?{left:`${o+n-f}px`,top:`${s-f}px`,width:`${d}px`,height:`${d}px`,cursor:"col-resize"}:{left:`${o-f}px`,top:`${s+n-f}px`,width:`${d}px`,height:`${d}px`,cursor:"row-resize"},g=u.useCallback(E=>{E.stopPropagation(),E.preventDefault();const y=t==="column"?E.clientX:E.clientY;m(!0),i==null||i(t,e);const p=h=>{const N=(t==="column"?h.clientX:h.clientY)-y;a==null||a(t,e,N)},x=h=>{const N=(t==="column"?h.clientX:h.clientY)-y;m(!1),l==null||l(t,e,N),window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",x)};window.addEventListener("pointermove",p),window.addEventListener("pointerup",x)},[t,e,i,a,l]);return r.jsx("div",{className:`${_e.handle} ${_e[t]} ${c?_e.dragging:""}`,style:v,onPointerDown:g,"data-testid":`grid-resize-handle-${t}-${e}`})});ne.displayName="GridResizeHandle";const Bn=u.memo(({paperPx:t,visible:e=!0,marginColor:n,zIndex:o=G.MARGIN_OVERLAY,className:s=""})=>{if(!e)return null;const i={position:"absolute",inset:0,pointerEvents:"none",width:`${t.canvas.width}px`,height:`${t.canvas.height}px`,zIndex:o},a={position:"absolute",backgroundColor:n||"rgba(0, 0, 0, 0.05)",pointerEvents:"none"};return r.jsxs("div",{className:s,style:i,role:"presentation","aria-label":"Printable area margin","data-testid":"margin-overlay",children:[t.margin.top>0&&r.jsx("div",{"data-testid":"margin-top",style:{...a,top:0,left:0,width:"100%",height:`${t.margin.top}px`}}),t.margin.bottom>0&&r.jsx("div",{"data-testid":"margin-bottom",style:{...a,bottom:0,left:0,width:"100%",height:`${t.margin.bottom}px`}}),t.margin.left>0&&r.jsx("div",{"data-testid":"margin-left",style:{...a,left:0,top:`${t.margin.top}px`,height:`${t.content.height}px`,width:`${t.margin.left}px`}}),t.margin.right>0&&r.jsx("div",{"data-testid":"margin-right",style:{...a,right:0,top:`${t.margin.top}px`,height:`${t.content.height}px`,width:`${t.margin.right}px`}})]})}),he=u.memo(({paperPx:t,gridPosPxs:e,gridDimensions:n,gridLineStyle:o,borderStyle:s,backgroundColor:i="#ffffff",boxShadow:a="0 2px 8px rgba(0, 0, 0, 0.1)",marginFillColor:l="rgba(0, 0, 0, 0.05)",showGridLines:c=!0,showMargins:m=!0,showBorder:d=!0,showResizeHandles:f=!1,showDimensionLabels:v=!1,onGridResize:g,onDimensionChange:E,className:y="",zIndex:p={}})=>{const[x,h]=u.useState(null),[w,N]=u.useState(null),[I,B]=u.useState(null),$=u.useRef(null);u.useEffect(()=>{const j=R=>{if(!$.current)return;const T=$.current.getBoundingClientRect();B({x:R.clientX-T.left,y:R.clientY-T.top})},_=R=>{if(!$.current)return;const T=$.current.getBoundingClientRect();(R.clientX<T.left||R.clientX>T.right||R.clientY<T.top||R.clientY>T.bottom)&&B(null)};return window.addEventListener("mousemove",j),window.addEventListener("mouseleave",_),()=>{window.removeEventListener("mousemove",j),window.removeEventListener("mouseleave",_)}},[]);const A=u.useMemo(()=>{if(!I)return!1;const j=t.content.width,_=t.content.height,R=t.margin.left,T=t.margin.top;return!(I.x>=R&&I.x<=R+j&&I.y>=T&&I.y<=T+_)},[I,t]),L=u.useCallback((j,_)=>{N({direction:j,index:_})},[]),S=u.useMemo(()=>{if(!x||!w)return null;const j=w.direction==="column"?e.cols:e.rows,_=w.index,R=j[_-1],T=x.position,O=R!==void 0?T-R:0,U=x.position,F=j[_+1],b=F!==void 0?F-U:0;return{direction:w.direction,prevIndex:_-1,prevSize:O,nextIndex:_,nextSize:b}},[x,w,e]),D=u.useCallback((j,_,R)=>{const T=j==="column"?e.cols:e.rows,O=T[_];if(O===void 0)return;const U=T[_-1],F=T[_+1],b=10;let M=R;if(U!==void 0){const P=U+b-O;M=Math.max(M,P)}if(F!==void 0){const P=F-b-O;M=Math.min(M,P)}h({direction:j,position:O+M})},[e]),k=u.useCallback((j,_,R)=>{const T=j==="column"?e.cols:e.rows,O=T[_];if(O===void 0){h(null);return}const U=T[_-1],F=T[_+1],b=10;let M=R;if(U!==void 0){const P=U+b-O;M=Math.max(M,P)}if(F!==void 0){const P=F-b-O;M=Math.min(M,P)}h(null),N(null),g==null||g(j,_,M)},[e,g]),C={position:"relative",width:"100%",height:"100%"};return r.jsxs("div",{ref:$,className:y,style:C,children:[r.jsx(kn,{canvasPx:t.canvas,backgroundColor:i,boxShadow:a,zIndex:(p==null?void 0:p.canvas)??G.GRID_CANVAS,className:y}),m&&r.jsx(Bn,{paperPx:t,visible:m,marginColor:l,zIndex:(p==null?void 0:p.margin)??G.MARGIN_OVERLAY,className:y}),c&&r.jsx(Gn,{gridPosPx:e,contentPx:t.content,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,lineStyle:o,visible:c,zIndex:(p==null?void 0:p.grid)??G.GRID_OVERLAY,dpi:W,className:y}),d&&r.jsx(An,{contentPx:t.content,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,borderStyle:s,visible:d,dpi:W,zIndex:(p==null?void 0:p.border)??G.BORDER_OVERLAY,className:y}),f&&g&&r.jsxs(r.Fragment,{children:[e.cols.map((j,_)=>{if(_===0||_===e.cols.length-1)return null;const R=`col-${_}`;return r.jsx(ne,{direction:"column",index:_,position:j,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,onResizeStart:L,onResize:D,onResizeEnd:k},R)}),e.rows.map((j,_)=>{if(_===0||_===e.rows.length-1)return null;const R=`row-${_}`;return r.jsx(ne,{direction:"row",index:_,position:j,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,onResizeStart:L,onResize:D,onResizeEnd:k},R)})]}),v&&n&&r.jsxs(r.Fragment,{children:[n.cols.map((j,_)=>{const R=e.cols[_],T=e.cols[_+1];if(R===void 0||T===void 0)return null;const O=(w==null?void 0:w.direction)==="column"&&(w.index===_||w.index===_+1);let U;S&&S.direction==="column"&&(S.prevIndex===_?U=S.prevSize:S.nextIndex===_&&(U=S.nextSize));const F=(R+T)/2,b=T-R,M=`col-dim-${_}`;return r.jsx(ee,{direction:"column",index:_,dimension:j,position:F,currentPxSize:b,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,isNearCursor:A||O,resizingPxSize:U,onDimensionChange:E},M)})," ",n.rows.map((j,_)=>{const R=e.rows[_],T=e.rows[_+1];if(R===void 0||T===void 0)return null;const O=(w==null?void 0:w.direction)==="row"&&(w.index===_||w.index===_+1),U=(R+T)/2,F=T-R,b=`row-dim-${_}`;return r.jsx(ee,{direction:"row",index:_,dimension:j,position:U,currentPxSize:F,marginLeftPx:t.margin.left,marginTopPx:t.margin.top,isNearCursor:A||O,onDimensionChange:E},b)})]}),x&&r.jsx("div",{style:{position:"absolute",left:x.direction==="column"?t.margin.left+x.position:t.margin.left,top:x.direction==="row"?t.margin.top+x.position:t.margin.top,width:x.direction==="column"?"2px":t.content.width,height:x.direction==="row"?"2px":t.content.height,backgroundColor:"#3b82f6",opacity:.5,pointerEvents:"none",zIndex:G.GRID_GHOST}})]})});class zo{constructor(){xe(this,"state",null);xe(this,"listeners",[])}start(e,n){this.state={kind:e,defaultSize:n},this.notify()}end(){this.state=null,this.notify()}get(){return this.state}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(n=>n!==e)}}notify(){for(const e of this.listeners)e(this.state)}}const zt=new zo;function Ne(t,e,n,o){if(e<0||e>=t.length)return t;const s=[...t],i=s[e],a=s[e+1];return!i||!a?t:i.unit==="fr"&&a.unit==="fr"?Wo(s,e,n,o):i.unit!=="fr"&&a.unit!=="fr"?Yo(s,e,n):i.unit==="fr"&&a.unit!=="fr"?mn(s,e,n,"next",o):mn(s,e,n,"current",o)}function Wo(t,e,n,o){const s=t[e],i=t[e+1];if(!s||!i)return t;const a=t.reduce((E,y)=>y.unit==="fr"?E+y.value:E,0),l=o/a,c=s.value*l,m=i.value*l,d=Math.max(10,c+n),f=Math.max(10,m-n),v=d/l,g=f/l;return t[e]={...s,value:Math.round(v*100)/100},t[e+1]={...i,value:Math.round(g*100)/100},t}function Yo(t,e,n){const o=t[e],s=t[e+1];if(!o||!s)return t;const i=V.fromDim(o),a=V.fromDim(s),l=Math.max(10,i+n),c=Math.max(10,a-n);return t[e]={...o,value:re(l,o.unit)},t[e+1]={...s,value:re(c,s.unit)},t}function mn(t,e,n,o,s){const i=t[e],a=t[e+1];if(!i||!a)return t;let l=0,c=0;for(const f of t)f.unit==="fr"?l+=f.value:c+=V.fromDim(f);const m=s-c,d=l>0?m/l:0;if(o==="next"){const f=V.fromDim(a),v=Math.max(10,f-n);t[e+1]={...a,value:re(v,a.unit)};const g=v-f,E=m-g,y=i.value*d,p=Math.max(10,y+n),x=l>0?p/E*l:1;t[e]={...i,value:Math.round(x*100)/100}}else{const f=V.fromDim(i),v=Math.max(10,f+n);t[e]={...i,value:re(v,i.unit)};const g=v-f,E=m-g,y=a.value*d,p=Math.max(10,y-n),x=l>0?p/E*l:1;t[e+1]={...a,value:Math.round(x*100)/100}}return t}function re(t,e){switch(e){case"px":return Math.round(t);case"mm":{const n=Y.fromPx(t);return Math.round(n*10)/10}case"cm":{const n=Y.fromPx(t);return Math.round(n/10*100)/100}case"inch":{const n=Y.fromPx(t);return Math.round(n/25.4*100)/100}case"pt":{const n=Y.fromPx(t);return Math.round(n/25.4*72*10)/10}case"fr":return 1;default:{const n=e;throw new Error(`Unsupported unit: ${n}`)}}}function Vn(t){if(t.length===0)return[];const e=[];let n=0;for(const o of t){et(o,"Pixel value");const s=o+n,i=Math.round(s);e.push(i),n=s-i}return e}const Ho=8,Xo=32,qo=64,Ko=512,hn=(t,e,n)=>Math.min(Math.max(t,e),n);function Ie(t){const e=t.length-1,n=e>=1?t[e]??0:0,o=t.length>=1?n/e:0,s=hn(Math.ceil(Math.log2(e+1)),Ho,Xo),i=hn(o*2,qo,Ko);return{step:s,windowPx:i}}function te(t,e){const n=e.length-1;if(n<=0||e[0]===void 0||t<e[0]||e[n]===void 0)return-1;if(t>=e[n])return n-1;let o=1,s=n;for(;o<=s;){const i=o+s>>>1,a=e[i];if(a===void 0){s=i-1;continue}a<=t?o=i+1:s=i-1}return o-1}function De(t,e,n){const o=t.length-1;let s=0;return i=>{if(o<=0||t[0]===void 0||i<t[0]||t[o]===void 0)return-1;if(i>=t[o])return o-1;const a=t[s],l=t[s+1];if(a===void 0||l===void 0)return-1;if(a<=i&&i<l)return s;const c=a-n,m=l+n;if(i<c||i>=m)return s=te(i,t),s;let d=0;const f=t[s+1];if(f!==void 0&&i>=f)for(;s+1<o;){const v=t[s+1];if(v===void 0||i<v)break;if(s++,++d>e)return s=te(i,t),s}else for(;s>0;){const v=t[s];if(v===void 0||i>=v)break;if(s--,++d>e)return s=te(i,t),s}return s}}function oe(t,e){if(t.length===0)return[];et(e,"Content size");let n=0,o=0;const s=t.map(l=>{if(et(l.value,"Grid dimension value"),l.unit==="fr")return n+=l.value,null;{const c=Y.fromDim(l);return o+=c,c}});if(n===0)return Nn(o,0,e,"Total fixed size"),s;const i=e-o;et(i,"Content size - fixed sizes");const a=i/n;return s.map((l,c)=>{const m=t[c];if(l!=null)return l;if(!m)throw new Error(`dims[${c}] is undefined`);return m.value*a})}function se(t,e=96){ue(e,"DPI"),de(e,"DPI");const n=t.map(s=>V.fromMm(s,e));return Vn(n)}function Zo(t,e,n){if(t.length===0)return[];ue(n,"DPI"),de(n,"DPI"),et(e,"Content size");const o=oe(t,e);return se(o,n)}function ie(t){const e={};for(const[n,o]of Object.entries(t))if(o!=null)if(typeof o=="object"&&!Array.isArray(o)&&o!==null){const s=ie(o);e[n]=s}else e[n]=o;return e}function Jo(t,e){const o={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}}[t];return e==="landscape"?{width:o.height,height:o.width}:o}function Un(t){t!=null&&t.title&&(document.title=t.title),t!=null&&t.removeScrollbars&&(document.body.style.overflow="hidden")}function Fn(t){t!=null&&t.restoreScrollbars&&(document.body.style.overflow="")}function $e(t,e){var s,i;const n=document.title,o=document.createElement("style");o.id="tatamicks-print-style",o.textContent=`
|
|
23
23
|
@media print {
|
|
24
24
|
/* bodyとhtmlのマージン・パディングをリセット */
|
|
25
25
|
html, body {
|
|
@@ -59,12 +59,12 @@ React keys must be passed directly to JSX without using spread:
|
|
|
59
59
|
color-adjust: exact !important;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
`;try{document.head.appendChild(s),e.classList.add("tatamicks-print-target"),t!=null&&t.title&&(document.title=t.title),(o=t==null?void 0:t.onBeforePrint)==null||o.call(t),window.print(),(a=t==null?void 0:t.onAfterPrint)==null||a.call(t)}finally{e.classList.remove("tatamicks-print-target");const i=document.getElementById("tatamicks-print-style");i&&i.remove(),document.title=n}}function Jo(e){Vn({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),Un({restoreScrollbars:!0}),window.removeEventListener("beforeprint",t),window.removeEventListener("afterprint",n)};window.addEventListener("beforeprint",t),window.addEventListener("afterprint",n),window.print()}function Qo(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 es(e){return e==="fr"||e==="px"||e==="%"}function hn(e){return Array.isArray(e)?e.every(t=>{if(typeof t!="object"||t===null)return!1;const n=t;return typeof n.value=="number"&&es(n.unit)}):!1}function ts(e){if(typeof e!="object"||e===null)return!1;const t=e;return hn(t.cols)&&hn(t.rows)}function ns(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 a=t.margin;for(const i of["top","right","bottom","left"]){const l=a[i];if(typeof l!="object"||l===null)return!1;const c=l;if(typeof c.value!="number"||typeof c.unit!="string")return!1}return!0}function rs(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)}function Fn(e){if(typeof e!="object"||e===null)throw new Error("Schema must be an object");const t=e;if(!ns(t.paper))throw new Error("Invalid paper definition");if(!ts(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(Qo))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(!rs(n[s]))throw new Error(`Invalid value in metaData.${s}`)}return t}function $t(e){try{const t=JSON.parse(e);return Fn(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 zn(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?!0:typeof e=="object"&&!Array.isArray(e)?Object.values(e).every(zn):!1}function Wn(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(!zn(t[n]))throw new Error(`Invalid value at key "${n}"`);return t}function Ct(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 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||{}),re=(e=>(e.MOVE="move",e.RESIZE="resize",e.INSERT="insert",e))(re||{}),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 os="_interactionBlock_7lg72_13",ss="_resizeHandle_7lg72_13",Yn={interactionBlock:os,resizeHandle:ss},is=[{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,a=o/2;return r.jsx(r.Fragment,{children:is.map(({id:i,cursor:l,x:c,y:d})=>{const m=c===50?`calc(50% - ${a}px)`:c===100?`calc(100% - ${a}px)`:`-${a}px`,x=d===50?`calc(50% - ${a}px)`:d===100?`calc(100% - ${a}px)`:`-${a}px`,g=t===i;return r.jsx("div",{className:Yn.resizeHandle,onPointerDown:b=>{b.stopPropagation(),e(b,i)},style:{position:"absolute",left:m,top:x,width:`${o}px`,height:`${o}px`,backgroundColor:g?n.borderColor:n.backgroundColor,border:`${n.borderWidth}px solid ${n.borderColor}`,borderRadius:n.borderRadius,cursor:l,zIndex:s,pointerEvents:"auto",boxSizing:"border-box",opacity:g?1:void 0,transition:"opacity 0.2s, background-color 0.2s, transform 0.2s",transform:g?"scale(1.2)":void 0},"data-testid":`resize-handle-${i}`},i)})})});Ut.displayName="ResizeHandles";const Hn=u.memo(({width:e,height:t,zIndex:n=B.BLOCK_SELECT_BORDER,borderStyle:s=Ke})=>{const o=u.useMemo(()=>new Ae(s),[s]),a={position:"absolute",inset:0,pointerEvents:"none",zIndex:n};return r.jsx("div",{style:a,children:r.jsx(Ie,{width:e,height:t,border:o})})}),Le=u.memo(({block:e,rect:t,showHandles:n=!1,onResizeStart:s,activeHandle:o,selectionStyle:a=Ke,handleStyle:i=ht,selectBorderZIndex:l=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:Yn.interactionBlock,style:d,"data-testid":"interaction-block","data-block-id":e.id,children:[r.jsx(Hn,{width:t.width,height:t.height,zIndex:l,borderStyle:a}),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:a,defaultSize:i,isOutside:l,selectionStyle:c,ghostZIndex:d=J.block_ghost,selectBorderZIndex:m=J.select_border,blockHandlesZIndex:x=J.block_handles})=>{const g=e[a];if(!g)return null;let b;if(l&&o){const y=Ne(g,{x:0,y:0,w:i.w,h:i.h}),f=n(y);b={left:o.x-f.width/2,top:o.y-f.height/2,width:f.width,height:f.height}}else{const y=t.cols-i.w,f=t.rows-i.h,p=Math.max(0,Math.min(s.col,y)),h=Math.max(0,Math.min(s.row,f)),_=Ne(g,{x:p,y:h,w:i.w,h:i.h});b=n(_)}const j=Ne(g,{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:`${b.left}px`,top:`${b.top}px`,width:`${b.width}px`,height:`${b.height}px`,opacity:l?.3:.6,filter:l?"grayscale(100%)":"none",zIndex:d},children:r.jsx(He,{id:j.id,plugin:g,props:j.props,value:j.initValue,onChange:()=>{},readOnly:!0,mode:ae.EDIT,blockSizePx:b,blockZIndex:d})}),r.jsx(Le,{block:j,rect:b,selectionStyle:c,selectBorderZIndex:m,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 h=s-p.layout.w,_=o-p.layout.h,I=Math.max(0,Math.min(p.layout.x+t,h)),E=Math.max(0,Math.min(p.layout.y+n,_));return[{blockId:p.id,x:I,y:E}]}const a=Math.min(...e.map(p=>p.layout.x)),i=Math.min(...e.map(p=>p.layout.y)),l=Math.max(...e.map(p=>p.layout.x+p.layout.w)),c=Math.max(...e.map(p=>p.layout.y+p.layout.h)),d=l-a,m=c-i,x=a+t,g=i+n,b=Math.max(0,Math.min(x,s-d)),j=Math.max(0,Math.min(g,o-m)),y=b-a,f=j-i;return e.map(p=>({blockId:p.id,x:p.layout.x+y,y:p.layout.y+f}))}const Wt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,selectedBlockIds:o,deltaCol:a,deltaRow:i,isOutside:l,currentMousePx:c,selectionStyle:d,ghostZIndex:m=J.block_ghost,selectBorderZIndex:x=J.select_border,blockHandlesZIndex:g=J.block_handles})=>{const b=o.map(y=>e.find(f=>f.id===y)).filter(Boolean),j=zt(b,a,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 f=e.find(I=>I.id===y);if(!f)return null;const p=t[f.kind];if(!p)return null;let h;if(l&&c){const I=s(f);h={left:c.x-I.width/2,top:c.y-I.height/2,width:I.width,height:I.height}}else{const I=j.find(M=>M.blockId===f.id);if(!I)return null;const E={...f,layout:{...f.layout,x:I.x,y:I.y}};h=s(E)}const _={...f,layout:{...f.layout,x:0,y:0}};return r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${h.left}px`,top:`${h.top}px`,width:`${h.width}px`,height:`${h.height}px`,opacity:l?.3:.5,filter:l?"grayscale(100%)":"none",zIndex:m},children:r.jsx(He,{id:_.id,plugin:p,props:_.props,value:_.initValue,onChange:()=>{},readOnly:!0,mode:ae.EDIT,blockSizePx:h,blockZIndex:m,className:"ghost-content"})}),r.jsx(Le,{block:_,rect:h,selectionStyle:d,selectBorderZIndex:x,blockHandlesZIndex:g})]},y)})})});Wt.displayName="MovingGhost";function Yt({layout:e,handle:t,deltaCol:n,deltaRow:s,gridCols:o,gridRows:a}){const i={...e};if(t===H.E||t===H.NE||t===H.SE){const l=o-e.x;i.w=Math.max(1,Math.min(e.w+n,l))}else if(t===H.W||t===H.NW||t===H.SW){const l=e.w-1,c=n>0?Math.min(n,l):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 l=a-e.y;i.h=Math.max(1,Math.min(e.h+s,l))}else if(t===H.N||t===H.NE||t===H.NW){const l=e.h-1,c=s>0?Math.min(s,l):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:a,deltaCol:i,deltaRow:l,isOutside:c,selectionStyle:d,ghostZIndex:m=J.block_ghost,selectBorderZIndex:x=J.select_border,blockHandlesZIndex:g=J.block_handles})=>{const b=e.find(h=>h.id===o),j=t[(b==null?void 0:b.kind)??""];if(!b||!j)return null;const y=Yt({layout:b.layout,handle:a,deltaCol:i,deltaRow:l,gridCols:n.cols,gridRows:n.rows}),f={...b,layout:y},p=s(f);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:m},children:r.jsx(He,{id:f.id,plugin:j,props:f.props,value:f.initValue,onChange:()=>{},readOnly:!0,mode:ae.EDIT,blockSizePx:p,blockZIndex:m,className:"resize-ghost-content"})}),r.jsx(Le,{block:f,rect:p,selectionStyle:d,selectBorderZIndex:x,blockHandlesZIndex:g})]},b.id)})});Ht.displayName="ResizeGhost";const Kt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,draggingState:s,getBlockRectPx:o,selectionStyle:a=Ke,ghostZIndex:i=J.block_ghost,selectBorderZIndex:l=J.select_border,blockHandlesZIndex:c=J.block_handles})=>{if(!s)return null;const d=s.currentGrid.col-s.startGrid.col,m=s.currentGrid.row-s.startGrid.row;switch(s.type){case re.MOVE:return r.jsx(Wt,{blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:o,selectedBlockIds:s.blockIds,deltaCol:d,deltaRow:m,isOutside:s.isOutside??!1,currentMousePx:s.currentMousePx,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c});case re.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:m,isOutside:s.isOutside??!1,selectionStyle:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c})}case re.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:a,ghostZIndex:i,selectBorderZIndex:l,blockHandlesZIndex:c}):null;default:return null}});Kt.displayName="DragLayer";const as=({id:e,plugin:t,props:n,value:s,onChange:o,onBlur:a,blockRectPx:i,zIndex:l=B.EDIT_BLOCK,validationState:c,className:d=""},m)=>{const x=u.useRef(null);u.useImperativeHandle(m,()=>({focus:()=>{var f;(f=x.current)==null||f.focus()}}),[]);const g=Bt(i,{zIndex:l,pointerEvents:"auto"}),b={width:i.width,height:i.height},j={id:e,props:n,value:s,onChange:o,onBlur:a,readOnly:!1,mode:ae.FORM,dimensions:{widthPx:b.width,heightPx:b.height},validationState:c},y=t.Renderer;return r.jsx("div",{className:d,style:g,"data-testid":"editing-block","data-block-id":e,"data-plugin-kind":t.kind,children:r.jsx(y,{ref:x,...j})})},ls=u.forwardRef(as),Kn=u.memo(ls);function Xn(e){const[t,n]=u.useState({mode:U.IDLE,selectedBlockIds:[],editingBlockId:null,...e}),s=u.useCallback(o=>{n(a=>{switch(o.type){case G.SELECT:{const i=o.blockIds;return{...a,mode:U.IDLE,selectedBlockIds:i}}case G.DESELECT:return{...a,mode:U.IDLE,selectedBlockIds:[]};case G.START_PRESS:{const i=o.selectedBlockIds||[o.blockId];return{...a,mode:U.PRESSING,dragging:{type:re.MOVE,blockIds:i,startGrid:o.startGrid,currentGrid:o.startGrid,isOutside:!1}}}case G.UPDATE_DRAG:{if(!a.dragging)return a;const i=o.currentGrid.col!==a.dragging.startGrid.col||o.currentGrid.row!==a.dragging.startGrid.row;return a.mode===U.PRESSING?i?{...a,mode:U.DRAGGING,dragging:{...a.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:{...a,dragging:{...a.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:a.mode===U.DRAGGING?{...a,dragging:{...a.dragging,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,isOutside:o.isOutside??!1}}:a}case G.END_DRAG:return{...a,mode:U.IDLE,dragging:void 0};case G.CANCEL_DRAG:return{...a,mode:U.IDLE,dragging:void 0};case G.EDIT:return{...a,mode:U.EDITING,editingBlockId:o.blockId};case G.END_EDIT:return{...a,mode:U.IDLE,editingBlockId:null};case G.START_INSERT:return{...a,mode:U.DRAGGING,dragging:{type:re.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{...a,mode:U.IDLE,dragging:void 0};case G.START_RESIZE:return{...a,mode:U.DRAGGING,dragging:{type:re.RESIZE,blockIds:[o.blockId],startGrid:o.startGrid,currentGrid:o.startGrid,handle:o.handle,isOutside:!1}};default:return a}})},[]);return[t,s]}const Xt=u.memo(({blocks:e,selectedBlockIds:t,isDragging:n,draggingState:s,getBlockRectPx:o,onResizeStart:a,selectionStyle:i=Ke,handleStyle:l=ht,selectBorderZIndex:c=J.select_border,blockHandlesZIndex:d=J.block_handles})=>{if(n&&(s==null?void 0:s.type)!==re.RESIZE)return null;const x=Array.from(new Set(t));return r.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:x.map(g=>{const b=e.find(f=>f.id===g);if(!b)return null;const y=(s==null?void 0:s.type)===re.RESIZE&&s.blockIds.includes(g)?s==null?void 0:s.handle:null;return r.jsx(Le,{block:b,rect:o(b),showHandles:!0,onResizeStart:(f,p)=>a(f,p,g),activeHandle:y,selectionStyle:i,handleStyle:l,selectBorderZIndex:c,blockHandlesZIndex:d},b.id)})})});Xt.displayName="SelectionLayer";function Zn(e,t,n,s){const o=n-t.w,a=s-t.h;return{x:Math.max(0,Math.min(e.x,o)),y:Math.max(0,Math.min(e.y,a))}}function Mt(e,t,n){const{x:s,y:o}=e;for(let a=t.length-1;a>=0;a--){const i=t[a];if(!i)continue;const l=n(i);if(s>=l.left&&s<=l.left+l.width&&o>=l.top&&o<=l.top+l.height)return i.id}return null}const Zt=u.memo(({blocks:e,pluginRegistry:t,gridLength:n,getBlockRectPx:s,getColIndex:o,getRowIndex:a,state:i,onChange:l,onBlockChange:c,scale:d=1,className:m="",selectionStyle:x,handleStyle:g,editBlockZIndex:b=B.EDIT_BLOCK,selectBorderZIndex:j=J.select_border,blockHandlesZIndex:y=J.block_handles,dragGhostZIndex:f=J.block_ghost})=>{const p=u.useRef(null),h=u.useRef(null);u.useEffect(()=>{i.mode===U.EDITING&&i.editingBlockId&&setTimeout(()=>{var w;(w=h.current)==null||w.focus()},0)},[i.mode,i.editingBlockId]),u.useEffect(()=>{const w=new Set(e.map(k=>k.id)),T=i.selectedBlockIds.filter(k=>w.has(k));T.length!==i.selectedBlockIds.length&&l({type:G.SELECT,blockIds:T,shiftKey:!1})},[e,i.selectedBlockIds,l]);const _=u.useCallback(w=>{var D;if(w.button!==0)return;const T=(D=p.current)==null?void 0:D.getBoundingClientRect();if(!T)return;const k=d??1,O={x:(w.clientX-T.left)/k,y:(w.clientY-T.top)/k},R=Mt(O,e,s);if(i.mode===U.EDITING){R!==i.editingBlockId&&(l({type:G.END_EDIT}),R||l({type:G.DESELECT}));return}const L=o(O.x),N=a(O.y);if(R){w.stopPropagation();const P=i.selectedBlockIds.includes(R);if(P&&w.shiftKey){const S=i.selectedBlockIds.filter(F=>F!==R);l({type:G.SELECT,blockIds:S,shiftKey:!0});return}else P?(w.currentTarget.setPointerCapture(w.pointerId),l({type:G.START_PRESS,blockId:R,startGrid:{col:L,row:N},selectedBlockIds:i.selectedBlockIds})):(w.currentTarget.setPointerCapture(w.pointerId),w.shiftKey?l({type:G.SELECT,blockIds:[...i.selectedBlockIds,R],shiftKey:!0}):(l({type:G.SELECT,blockIds:[R]}),l({type:G.START_PRESS,blockId:R,startGrid:{col:L,row:N},selectedBlockIds:[R]})))}else w.stopPropagation(),l({type:G.DESELECT})},[e,s,o,a,i.mode,i.selectedBlockIds,l,d,i.editingBlockId]),I=u.useCallback(w=>{var X;if(i.mode!==U.PRESSING&&i.mode!==U.DRAGGING||!i.dragging)return;const T=(X=p.current)==null?void 0:X.getBoundingClientRect();if(!T)return;const k=d??1,O=T.width/k,R=T.height/k,L=(w.clientX-T.left)/k,N=(w.clientY-T.top)/k,D=i.dragging.type!==re.RESIZE&&(L<0||L>O||N<0||N>R),P=Math.max(0,Math.min(L,O)),S=Math.max(0,Math.min(N,R)),F=o(P),K=a(S);l({type:G.UPDATE_DRAG,currentGrid:{col:F,row:K},currentMousePx:{x:L,y:N},isOutside:D})},[i.mode,i.dragging,o,a,l,d]),E=u.useCallback(w=>{if(i.mode===U.DRAGGING&&i.dragging){if(i.dragging.isOutside){i.dragging.type===re.MOVE&&(c==null||c({type:ce.DELETE,blockIds:i.dragging.blockIds}),l({type:G.DESELECT})),l({type:G.END_DRAG}),w.currentTarget.releasePointerCapture(w.pointerId);return}const T=i.dragging.currentGrid.col-i.dragging.startGrid.col,k=i.dragging.currentGrid.row-i.dragging.startGrid.row;if(i.dragging.type===re.MOVE){if(T!==0||k!==0){const O=i.dragging.blockIds.map(N=>e.find(D=>D.id===N)).filter(Boolean);if(O.length===0){l({type:G.END_DRAG}),w.currentTarget.releasePointerCapture(w.pointerId);return}const R=zt(O,T,k,n.cols,n.rows),L=O.map(N=>{const D=R.find(P=>P.blockId===N.id);return D?{...N,layout:{...N.layout,x:D.x,y:D.y}}:N});c==null||c({type:ce.MOVE,blockIds:i.dragging.blockIds,blocks:L})}}else if(i.dragging.type===re.INSERT){const{pluginKind:O,currentGrid:R,defaultSize:L}=i.dragging;if(O&&L){const N=t[O];if(N){const{x:D,y:P}=Zn({x:R.col,y:R.row},{w:L.w,h:L.h},n.cols,n.rows),S=Ne(N,{x:D,y:P,w:L.w,h:L.h});c==null||c({type:ce.ADD,blockIds:[S.id],blocks:[S]})}}}else if(i.dragging.type===re.RESIZE){const O=i.dragging.blockIds[0],R=e.find(N=>N.id===O),L=i.dragging.handle;if(R&&L&&(T!==0||k!==0)){const N=Yt({layout:R.layout,handle:L,deltaCol:T,deltaRow:k,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:ce.RESIZE,blockIds:[R.id],blocks:[{...R,layout:N}]}))}}l({type:G.END_DRAG})}else i.mode===U.PRESSING&&i.dragging&&(i.dragging.isOutside&&i.dragging.type===re.MOVE&&(c==null||c({type:ce.DELETE,blockIds:i.dragging.blockIds}),l({type:G.DESELECT})),l({type:G.CANCEL_DRAG}));w.currentTarget.releasePointerCapture(w.pointerId)},[i.mode,i.dragging,e,n,t,c,l]),M=u.useCallback(w=>{var L;const T=(L=p.current)==null?void 0:L.getBoundingClientRect();if(!T)return;const k=d??1,O={x:(w.clientX-T.left)/k,y:(w.clientY-T.top)/k},R=Mt(O,e,s);R&&(i.selectedBlockIds.includes(R)||l({type:G.SELECT,blockIds:[R]}),l({type:G.EDIT,blockId:R}))},[e,s,l,d,i.selectedBlockIds]),$=u.useCallback(w=>{var T;if((i.mode===U.PRESSING||i.mode===U.DRAGGING)&&i.dragging){const k=(T=p.current)==null?void 0:T.getBoundingClientRect();if(k){const O=d??1,R=(w.clientX-k.left)/O,L=(w.clientY-k.top)/O,N=k.width/O,D=k.height/O,P=Math.max(0,Math.min(R,N)),S=Math.max(0,Math.min(L,D));l({type:G.UPDATE_DRAG,currentGrid:{col:o(P),row:a(S)},currentMousePx:{x:R,y:L},isOutside:!0})}}},[i.mode,i.dragging,d,o,a,l]);return r.jsxs("div",{ref:p,className:m,style:{position:"absolute",inset:0,zIndex:B.INTERACTION_LAYER_BASE,pointerEvents:"auto",touchAction:"none"},role:"application","aria-label":"Interactive canvas layer",tabIndex:-1,onPointerDown:_,onPointerMove:I,onPointerUp:E,onPointerLeave:$,onDoubleClick:M,"data-testid":"interaction-layer",children:[i.editingBlockId&&(()=>{const w=e.find(k=>k.id===i.editingBlockId),T=w?t[w.kind]:null;return!w||!T?null:r.jsx(Kn,{ref:h,id:w.id,plugin:T,props:w.props,value:w.initValue,onChange:k=>{c==null||c({type:ce.UPDATE,blockIds:[w.id],blocks:[{...w,initValue:k}]})},onBlur:k=>{c==null||c({type:ce.UPDATE,blockIds:[w.id],blocks:[{...w,initValue:k}]})},blockRectPx:s(w),zIndex:b})})(),r.jsx(Xt,{blocks:e,selectedBlockIds:i.selectedBlockIds,isDragging:i.mode===U.DRAGGING,draggingState:i.dragging,getBlockRectPx:s,onResizeStart:(w,T,k)=>{var N;const O=(N=p.current)==null?void 0:N.getBoundingClientRect();if(!O)return;i.mode===U.EDITING&&l({type:G.END_EDIT}),w.currentTarget.setPointerCapture(w.pointerId);const R=d??1,L={x:(w.clientX-O.left)/R,y:(w.clientY-O.top)/R};l({type:G.START_RESIZE,blockId:k,handle:T,startGrid:{col:o(L.x),row:a(L.y)}})},selectionStyle:x,handleStyle:g,selectBorderZIndex:j,blockHandlesZIndex:y}),r.jsx(Kt,{blocks:e,pluginRegistry:t,gridLength:n,draggingState:i.dragging,getBlockRectPx:s,selectionStyle:x,ghostZIndex:f,selectBorderZIndex:j,blockHandlesZIndex:y})]})});Zt.displayName="InteractionLayer";function Xe(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]),a=u.useMemo(()=>Y.fromDim(e.margin.top),[e.margin.top]),i=u.useMemo(()=>Y.fromDim(e.margin.bottom),[e.margin.bottom]),l=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-l-c,[s,l,c]),m=u.useMemo(()=>o-a-i,[o,a,i]),x=u.useMemo(()=>ot(t.cols,d),[t.cols,d]),g=u.useMemo(()=>ot(t.rows,m),[t.rows,m]),b=u.useMemo(()=>V.fromMm(s,n),[s,n]),j=u.useMemo(()=>V.fromMm(o,n),[o,n]),y=u.useMemo(()=>V.fromMm(a,n),[a,n]),f=u.useMemo(()=>V.fromMm(i,n),[i,n]),p=u.useMemo(()=>V.fromMm(l,n),[l,n]),h=u.useMemo(()=>V.fromMm(c,n),[c,n]),_=u.useMemo(()=>V.fromMm(d,n),[d,n]),I=u.useMemo(()=>V.fromMm(m,n),[m,n]),E=u.useMemo(()=>st(x,n),[x,n]),M=u.useMemo(()=>st(g,n),[g,n]),$=u.useMemo(()=>{const A=[0];for(const z of E){const he=A[A.length-1]??0;A.push(he+z)}return A},[E]),w=u.useMemo(()=>{const A=[0];for(const z of M){const he=A[A.length-1]??0;A.push(he+z)}return A},[M]),{step:T,windowPx:k}=u.useMemo(()=>Nt($),[$]),{step:O,windowPx:R}=u.useMemo(()=>Nt(w),[w]),L=u.useMemo(()=>It($,T,k),[$,T,k]),N=u.useMemo(()=>It(w,O,R),[w,O,R]),D=u.useCallback(A=>L(A-p),[L,p]),P=u.useCallback(A=>N(A-y),[N,y]),S=u.useMemo(()=>({cols:$,rows:w}),[$,w]),F=u.useMemo(()=>({width:b,height:j}),[b,j]),K=u.useMemo(()=>({top:y,bottom:f,left:p,right:h}),[y,f,p,h]),X=u.useMemo(()=>({width:_,height:I}),[_,I]),v=u.useMemo(()=>({canvas:F,margin:K,content:X}),[F,K,X]),C=u.useCallback(A=>{const{x:z,y:he,w:Oe,h:Z}=A.layout,ue=S.cols,be=S.rows;if(!ue.length||!be.length)return{left:0,top:0,width:0,height:0};const Ze=Math.min(Math.max(0,z),ue.length-1),mr=Math.min(Math.max(0,z+Oe),ue.length-1),an=Math.min(Math.max(0,he),be.length-1),hr=Math.min(Math.max(0,he+Z),be.length-1),fr=(ue[Ze]??0)+p,pr=(be[an]??0)+y,xr=(ue[mr]??0)-(ue[Ze]??0),gr=(be[hr]??0)-(be[an]??0);return{left:fr,top:pr,width:xr,height:gr}},[S,p,y]);return{paperPx:v,gridPosPx:S,getColIndex:D,getRowIndex:P,getBlockRectPx:C}}const qn=({schema:e,values:t,pluginRegistry:n,onValueChange:s,scale:o=1,className:a})=>{const{paperPx:i,gridPosPx:l,getBlockRectPx:c}=Xe(e.paper,e.grid,W),d=u.useCallback((m,x)=>{s&&s(m,x)},[s]);return r.jsxs("div",{className:a,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(mt,{paperPx:i,gridPosPxs:l,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(Se,{blocks:e.blocks,pluginRegistry:n,mode:ae.EDIT,values:t,getBlockRectPx:c,onValueChange:d,showGuides:!0,showBorder:!0})]})};qn.displayName="NoteEdit";const Jn=u.memo(qn),Qn=({schema:e,pluginRegistry:t,onSchemaChange:n,onSelectionChange:s,scale:o=1,className:a})=>{const[i,l]=Xn(),c=u.useRef(null),{paperPx:d,gridPosPx:m,getBlockRectPx:x,getColIndex:g,getRowIndex:b}=Xe(e.paper,e.grid,W),j=u.useCallback(E=>{if(n)switch(E.type){case ce.MOVE:case ce.RESIZE:{if(!E.blocks)return;const M=e.blocks.map($=>{var T;return((T=E.blocks)==null?void 0:T.find(k=>k.id===$.id))||$});n({...e,blocks:M});break}case ce.ADD:{if(!E.blocks)return;n({...e,blocks:[...e.blocks,...E.blocks]});break}case ce.DELETE:{const M=new Set(E.blockIds),$=e.blocks.filter(w=>!M.has(w.id));n({...e,blocks:$});break}case ce.UPDATE:{if(!E.blocks)return;const M=e.blocks.map($=>{var O;const w=(O=E.blocks)==null?void 0:O.find(R=>R.id===$.id);if(!w)return $;const T=w.style?it(w.style):w.style,k=w.props?it(w.props):w.props;return{...$,...w,style:T,props:k}});n({...e,blocks:M});break}}},[e,n]),y=u.useCallback((E,M)=>{if(!n)return;const $=e.blocks.map(w=>w.id===E?{...w,initValue:M}:w);n({...e,blocks:$})},[e,n]);u.useEffect(()=>{s&&s(i.selectedBlockIds)},[i.selectedBlockIds,s]),u.useEffect(()=>{const E=ze.subscribe(M=>{var $;!M&&i.mode===U.DRAGGING&&(($=i.dragging)==null?void 0:$.type)===re.INSERT&&l({type:G.CANCEL_INSERT})});return()=>E()},[i.mode,i.dragging,l]),u.useEffect(()=>{const E=M=>{if(i.selectedBlockIds.length===0)return;const $=M.target;$ instanceof HTMLElement&&$.closest('[data-sidebar="true"]')||c.current&&!c.current.contains($)&&l({type:G.DESELECT})};return document.addEventListener("mousedown",E),()=>{document.removeEventListener("mousedown",E)}},[i.selectedBlockIds,l]);const f=u.useCallback((E,M,$)=>{if(!n)return;const w=M-1;if(E==="column"){const T=jt(e.grid.cols,w,$,d.content.width);n({...e,grid:{...e.grid,cols:T}})}else{const T=jt(e.grid.rows,w,$,d.content.height);n({...e,grid:{...e.grid,rows:T}})}},[e,d,n]),p=u.useCallback((E,M,$)=>{if(n)if(E==="column"){const w=[...e.grid.cols];w[M]=$,n({...e,grid:{...e.grid,cols:w}})}else{const w=[...e.grid.rows];w[M]=$,n({...e,grid:{...e.grid,rows:w}})}},[n,e]),h=u.useMemo(()=>e.blocks.reduce((E,M)=>(E[M.id]=M.initValue,E),{}),[e.blocks]),_=u.useCallback(()=>{const E=ze.get();E&&(i.mode===U.DRAGGING||i.dragging||l({type:G.START_INSERT,pluginKind:E.kind,defaultSize:E.defaultSize}))},[i.mode,i.dragging,l]),I=u.useCallback(()=>{},[]);return r.jsxs("div",{ref:c,className:a,onPointerEnter:_,onPointerLeave:I,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:o!==1?`scale(${o})`:void 0,transformOrigin:"top center"},children:[r.jsx(mt,{paperPx:d,gridPosPxs:m,gridDimensions:{cols:e.grid.cols,rows:e.grid.rows},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:f,onDimensionChange:p,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(Se,{blocks:e.blocks,pluginRegistry:t,mode:ae.FORM,values:h,selectedBlockIds:i.selectedBlockIds,getBlockRectPx:x,onValueChange:y,showGuides:!0,showBorder:!0}),r.jsx(Zt,{blocks:e.blocks,gridLength:{cols:e.grid.cols.length,rows:e.grid.rows.length},pluginRegistry:t,getBlockRectPx:x,getColIndex:g,getRowIndex:b,state:i,onChange:l,onBlockChange:j,scale:o})]})};Qn.displayName="NoteForm";const er=u.memo(Qn),tr=({schema:e,values:t,pluginRegistry:n,scale:s=1,className:o})=>{const{paperPx:a,gridPosPx:i,getBlockRectPx:l}=Xe(e.paper,e.grid,W);return r.jsxs("div",{className:o,style:{position:"relative",width:`${a.canvas.width}px`,height:`${a.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(mt,{paperPx:a,gridPosPxs:i,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(Se,{blocks:e.blocks,pluginRegistry:n,mode:ae.VIEW,values:t,getBlockRectPx:l,showGuides:!1,showBorder:!0})]})};tr.displayName="NoteView";const nr=u.memo(tr),rr=({schema:e,values:t,mode:n,pluginRegistry:s,onSchemaChange:o,onValuesChange:a,onSelectionChange:i,scale:l=1,className:c})=>{const d=u.useCallback((m,x)=>{if(a)if(x==null){const{[m]:g,...b}=t;a(b)}else a({...t,[m]:x})},[t,a]);return n===ae.FORM?r.jsx(er,{schema:e,pluginRegistry:s,onSchemaChange:o,onSelectionChange:i,scale:l,className:c}):n===ae.EDIT?r.jsx(Jn,{schema:e,values:t,pluginRegistry:s,onValueChange:d,scale:l,className:c}):r.jsx(nr,{schema:e,values:t,pluginRegistry:s,scale:l,className:c})};rr.displayName="NoteEditor";const cs=u.memo(rr),or=({schema:e,values:t,pluginRegistry:n,className:s},o)=>{const a=u.useRef(null),{paperPx:i,getBlockRectPx:l}=Xe(e.paper,e.grid,W);return u.useEffect(()=>{const{size:c}=e.paper,d=Y.fromDim(c.width),m=Y.fromDim(c.height),x=document.getElementById("printable-note-page-style");x&&x.remove();const g=document.createElement("style");return g.id="printable-note-page-style",g.textContent=`
|
|
62
|
+
`;try{document.head.appendChild(o),t.classList.add("tatamicks-print-target"),e!=null&&e.title&&(document.title=e.title),(s=e==null?void 0:e.onBeforePrint)==null||s.call(e),window.print(),(i=e==null?void 0:e.onAfterPrint)==null||i.call(e)}finally{t.classList.remove("tatamicks-print-target");const a=document.getElementById("tatamicks-print-style");a&&a.remove(),document.title=n}}function Qo(t){Un({title:t==null?void 0:t.title,removeScrollbars:!0});const e=()=>{var o;(o=t==null?void 0:t.onBeforePrint)==null||o.call(t)},n=()=>{var o;(o=t==null?void 0:t.onAfterPrint)==null||o.call(t),Fn({restoreScrollbars:!0}),window.removeEventListener("beforeprint",e),window.removeEventListener("afterprint",n)};window.addEventListener("beforeprint",e),window.addEventListener("afterprint",n),window.print()}function ts(t){if(typeof t!="object"||t===null)return!1;const e=t;if(typeof e.id!="string"||typeof e.kind!="string"||typeof e.layout!="object"||e.layout===null)return!1;const n=e.layout;return!(typeof n.x!="number"||typeof n.y!="number"||typeof n.w!="number"||typeof n.h!="number"||e.props!==void 0&&typeof e.props!="object")}function es(t){return t==="fr"||t==="px"||t==="%"}function fn(t){return Array.isArray(t)?t.every(e=>{if(typeof e!="object"||e===null)return!1;const n=e;return typeof n.value=="number"&&es(n.unit)}):!1}function ns(t){if(typeof t!="object"||t===null)return!1;const e=t;return fn(e.cols)&&fn(e.rows)}function rs(t){if(typeof t!="object"||t===null)return!1;const e=t;if(typeof e.size!="object"||e.size===null)return!1;const n=e.size;if(typeof n.preset!="string"||typeof n.width!="object"||n.width===null)return!1;const o=n.width;if(typeof o.value!="number"||typeof o.unit!="string"||typeof n.height!="object"||n.height===null)return!1;const s=n.height;if(typeof s.value!="number"||typeof s.unit!="string"||typeof e.margin!="object"||e.margin===null)return!1;const i=e.margin;for(const a of["top","right","bottom","left"]){const l=i[a];if(typeof l!="object"||l===null)return!1;const c=l;if(typeof c.value!="number"||typeof c.unit!="string")return!1}return!0}function os(t){return t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="object"&&!Array.isArray(t)}function zn(t){if(typeof t!="object"||t===null)throw new Error("Schema must be an object");const e=t;if(!rs(e.paper))throw new Error("Invalid paper definition");if(!ns(e.grid))throw new Error("Invalid grid definition");if(!Array.isArray(e.blocks))throw new Error("blocks must be an array");if(!e.blocks.every(ts))throw new Error("Invalid block definition in blocks array");if(e.metaData!==void 0){if(typeof e.metaData!="object"||e.metaData===null)throw new Error("metaData must be an object if provided");const n=e.metaData;for(const o in n)if(!os(n[o]))throw new Error(`Invalid value in metaData.${o}`)}return e}function Te(t){try{const e=JSON.parse(t);return zn(e)}catch(e){throw e instanceof SyntaxError?new Error(`Invalid JSON format: ${e.message}`):e}}function Re(t,e=!1){try{return e?JSON.stringify(t,null,2):JSON.stringify(t)}catch(n){throw new Error(`Failed to serialize schema: ${n instanceof Error?n.message:"Unknown error"}`)}}function Wn(t){return t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"?!0:typeof t=="object"&&!Array.isArray(t)?Object.values(t).every(Wn):!1}function Yn(t){if(typeof t!="object"||t===null)throw new Error("Values must be an object");if(Array.isArray(t))throw new Error("Values must be an object, not an array");const e=t;for(const n in e)if(!Wn(e[n]))throw new Error(`Invalid value at key "${n}"`);return e}function Me(t){try{const e=JSON.parse(t);return Yn(e)}catch(e){throw e instanceof SyntaxError?new Error(`Invalid JSON format: ${e.message}`):e}}function Ce(t,e=!1){try{return e?JSON.stringify(t,null,2):JSON.stringify(t)}catch(n){throw new Error(`Failed to serialize values: ${n instanceof Error?n.message:"Unknown error"}`)}}const Xt={all:{color:"#3b82f688",width:{value:4,unit:"px"},type:dt.SOLID}},fe={size:12,backgroundColor:"#ffffff",borderColor:"#3b82f6",borderWidth:1,borderRadius:"50%"},Z={base:G.INTERACTION_LAYER_BASE,select_block:G.SELECT_BLOCK,block_ghost:G.BLOCK_GHOST,hover_outline:G.HOVER_OUTLINE,edit_block:G.EDIT_BLOCK,grid_ghost:G.GRID_GHOST,grid_handles:G.GRID_HANDLES,select_border:G.BLOCK_SELECT_BORDER,block_handles:G.BLOCK_HANDLES,rubber_band:G.RUBBER_BAND};var lt=(t=>(t.IDLE="idle",t.PRESSING="pressing",t.DRAGGING="dragging",t.EDITING="editing",t))(lt||{}),X=(t=>(t.N="n",t.NE="ne",t.E="e",t.SE="se",t.S="s",t.SW="sw",t.W="w",t.NW="nw",t))(X||{}),nt=(t=>(t.MOVE="move",t.RESIZE="resize",t.INSERT="insert",t))(nt||{}),H=(t=>(t.START_PRESS="startPress",t.UPDATE_DRAG="updateDrag",t.END_DRAG="endDrag",t.CANCEL_DRAG="cancelDrag",t.EDIT="edit",t.END_EDIT="endEdit",t.START_INSERT="startInsert",t.CANCEL_INSERT="cancelInsert",t.START_RESIZE="startResize",t))(H||{});function ae(t){return t.editingBlockId!==null?"editing":t.dragging?t.dragging.type==="insert"||t.dragging.type==="resize"||t.dragging.currentGrid.col!==t.dragging.startGrid.col||t.dragging.currentGrid.row!==t.dragging.startGrid.row?"dragging":"pressing":"idle"}const ss="_interactionBlock_145kg_7",is="_resizeHandle_145kg_7",Hn={interactionBlock:ss,resizeHandle:is},as=[{id:X.NW,cursor:"nwse-resize",x:0,y:0},{id:X.N,cursor:"ns-resize",x:50,y:0},{id:X.NE,cursor:"nesw-resize",x:100,y:0},{id:X.W,cursor:"ew-resize",x:0,y:50},{id:X.E,cursor:"ew-resize",x:100,y:50},{id:X.SW,cursor:"nesw-resize",x:0,y:100},{id:X.S,cursor:"ns-resize",x:50,y:100},{id:X.SE,cursor:"nwse-resize",x:100,y:100}],Fe=u.memo(({onResizeStart:t,activeHandle:e,handleStyle:n=fe,zIndex:o=G.BLOCK_HANDLES})=>{const s=n.size,i=s/2;return r.jsx(r.Fragment,{children:as.map(({id:a,cursor:l,x:c,y:m})=>{const d=c===50?`calc(50% - ${i}px)`:c===100?`calc(100% - ${i}px)`:`-${i}px`,f=m===50?`calc(50% - ${i}px)`:m===100?`calc(100% - ${i}px)`:`-${i}px`,v=e===a;return r.jsx("div",{className:Hn.resizeHandle,onPointerDown:g=>{g.stopPropagation(),t(g,a)},style:{position:"absolute",left:d,top:f,width:`${s}px`,height:`${s}px`,backgroundColor:v?n.borderColor:n.backgroundColor,border:`${n.borderWidth}px solid ${n.borderColor}`,borderRadius:n.borderRadius,cursor:l,zIndex:o,pointerEvents:"auto",boxSizing:"border-box",opacity:v?1:void 0,transition:"opacity 0.2s, background-color 0.2s, transform 0.2s",transform:v?"scale(1.2)":void 0},"data-testid":`resize-handle-${a}`},a)})})});Fe.displayName="ResizeHandles";const Xn=u.memo(({width:t,height:e,zIndex:n=G.BLOCK_SELECT_BORDER,borderStyle:o=Xt})=>{const s=u.useMemo(()=>new kt(o),[o]),i={position:"absolute",inset:0,pointerEvents:"none",zIndex:n};return r.jsx("div",{style:i,children:r.jsx(It,{width:t,height:e,border:s})})}),Lt=u.memo(({block:t,rect:e,showHandles:n=!1,onResizeStart:o,activeHandle:s,selectionStyle:i=Xt,handleStyle:a=fe,selectBorderZIndex:l=Z.select_border,blockHandlesZIndex:c=Z.block_handles})=>{const m={position:"absolute",left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none"};return r.jsxs("div",{className:Hn.interactionBlock,style:m,"data-testid":"interaction-block","data-block-id":t.id,children:[r.jsx(Xn,{width:e.width,height:e.height,zIndex:l,borderStyle:i}),n&&o&&r.jsx(Fe,{onResizeStart:o,activeHandle:s,handleStyle:a,zIndex:c})]})});Lt.displayName="InteractionBlock";const ze=u.memo(({pluginRegistry:t,gridLength:e,getBlockRectPx:n,currentGrid:o,currentMousePx:s,pluginKind:i,defaultSize:a,isOutside:l,selectionStyle:c,ghostZIndex:m=Z.block_ghost,selectBorderZIndex:d=Z.select_border,blockHandlesZIndex:f=Z.block_handles})=>{const v=t[i];if(!v)return null;let g;if(l&&s){const y=Nt(v,{x:0,y:0,w:a.w,h:a.h}),p=n(y);g={left:s.x-p.width/2,top:s.y-p.height/2,width:p.width,height:p.height}}else{const y=e.cols-a.w,p=e.rows-a.h,x=Math.max(0,Math.min(o.col,y)),h=Math.max(0,Math.min(o.row,p)),w=Nt(v,{x,y:h,w:a.w,h:a.h});g=n(w)}const E=Nt(v,{x:0,y:0,w:a.w,h:a.h});return r.jsxs("div",{"data-testid":"insert-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:[r.jsx("div",{style:{position:"absolute",left:`${g.left}px`,top:`${g.top}px`,width:`${g.width}px`,height:`${g.height}px`,opacity:l?.3:.6,filter:l?"grayscale(100%)":"none",zIndex:m},children:r.jsx(Ht,{id:E.id,plugin:v,props:E.props,value:E.initValue,onChange:()=>{},readOnly:!0,mode:it.EDIT,blockSizePx:g,blockZIndex:m})}),r.jsx(Lt,{block:E,rect:g,selectionStyle:c,selectBorderZIndex:d,blockHandlesZIndex:f})]})});ze.displayName="InsertGhost";function We(t,e,n,o,s){if(t.length===0)return[];if(t.length===1){const x=t[0];if(!x)return[];const h=o-x.layout.w,w=s-x.layout.h,N=Math.max(0,Math.min(x.layout.x+e,h)),I=Math.max(0,Math.min(x.layout.y+n,w));return[{blockId:x.id,x:N,y:I}]}const i=Math.min(...t.map(x=>x.layout.x)),a=Math.min(...t.map(x=>x.layout.y)),l=Math.max(...t.map(x=>x.layout.x+x.layout.w)),c=Math.max(...t.map(x=>x.layout.y+x.layout.h)),m=l-i,d=c-a,f=i+e,v=a+n,g=Math.max(0,Math.min(f,o-m)),E=Math.max(0,Math.min(v,s-d)),y=g-i,p=E-a;return t.map(x=>({blockId:x.id,x:x.layout.x+y,y:x.layout.y+p}))}const Ye=u.memo(({blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:o,selectedBlockIds:s,deltaCol:i,deltaRow:a,isOutside:l,currentMousePx:c,selectionStyle:m,ghostZIndex:d=Z.block_ghost,selectBorderZIndex:f=Z.select_border,blockHandlesZIndex:v=Z.block_handles})=>{const g=s.map(y=>t.find(p=>p.id===y)).filter(Boolean),E=We(g,i,a,n.cols,n.rows);return r.jsx("div",{"data-testid":"moving-ghost",style:{position:"absolute",inset:0,pointerEvents:"none"},children:s.map(y=>{const p=t.find(N=>N.id===y);if(!p)return null;const x=e[p.kind];if(!x)return null;let h;if(l&&c){const N=o(p);h={left:c.x-N.width/2,top:c.y-N.height/2,width:N.width,height:N.height}}else{const N=E.find(B=>B.blockId===p.id);if(!N)return null;const I={...p,layout:{...p.layout,x:N.x,y:N.y}};h=o(I)}const w={...p,layout:{...p.layout,x:0,y:0}};return r.jsxs("div",{children:[r.jsx("div",{style:{position:"absolute",left:`${h.left}px`,top:`${h.top}px`,width:`${h.width}px`,height:`${h.height}px`,opacity:l?.3:.5,filter:l?"grayscale(100%)":"none",zIndex:d},children:r.jsx(Ht,{id:w.id,plugin:x,props:w.props,value:w.initValue,onChange:()=>{},readOnly:!0,mode:it.EDIT,blockSizePx:h,blockZIndex:d,className:"ghost-content"})}),r.jsx(Lt,{block:w,rect:h,selectionStyle:m,selectBorderZIndex:f,blockHandlesZIndex:v})]},y)})})});Ye.displayName="MovingGhost";function He({layout:t,handle:e,deltaCol:n,deltaRow:o,gridCols:s,gridRows:i}){const a={...t};if(e===X.E||e===X.NE||e===X.SE){const l=s-t.x;a.w=Math.max(1,Math.min(t.w+n,l))}else if(e===X.W||e===X.NW||e===X.SW){const l=t.w-1,c=n>0?Math.min(n,l):n;t.x+c>=0?(a.x=t.x+c,a.w=t.w-c):(a.x=0,a.w=t.w+t.x)}if(e===X.S||e===X.SE||e===X.SW){const l=i-t.y;a.h=Math.max(1,Math.min(t.h+o,l))}else if(e===X.N||e===X.NE||e===X.NW){const l=t.h-1,c=o>0?Math.min(o,l):o;t.y+c>=0?(a.y=t.y+c,a.h=t.h-c):(a.y=0,a.h=t.h+t.y)}return a}const Xe=u.memo(({blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:o,blockId:s,handle:i,deltaCol:a,deltaRow:l,isOutside:c,selectionStyle:m,ghostZIndex:d=Z.block_ghost,selectBorderZIndex:f=Z.select_border,blockHandlesZIndex:v=Z.block_handles})=>{const g=t.find(h=>h.id===s),E=e[(g==null?void 0:g.kind)??""];if(!g||!E)return null;const y=He({layout:g.layout,handle:i,deltaCol:a,deltaRow:l,gridCols:n.cols,gridRows:n.rows}),p={...g,layout:y},x=o(p);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:`${x.left}px`,top:`${x.top}px`,width:`${x.width}px`,height:`${x.height}px`,opacity:c?.3:.5,filter:c?"grayscale(100%)":"none",zIndex:d},children:r.jsx(Ht,{id:p.id,plugin:E,props:p.props,value:p.initValue,onChange:()=>{},readOnly:!0,mode:it.EDIT,blockSizePx:x,blockZIndex:d,className:"resize-ghost-content"})}),r.jsx(Lt,{block:p,rect:x,selectionStyle:m,selectBorderZIndex:f,blockHandlesZIndex:v})]},g.id)})});Xe.displayName="ResizeGhost";const qe=u.memo(({blocks:t,pluginRegistry:e,gridLength:n,draggingState:o,getBlockRectPx:s,selectionStyle:i=Xt,ghostZIndex:a=Z.block_ghost,selectBorderZIndex:l=Z.select_border,blockHandlesZIndex:c=Z.block_handles})=>{if(!o)return null;const m=o.currentGrid.col-o.startGrid.col,d=o.currentGrid.row-o.startGrid.row;switch(o.type){case nt.MOVE:return r.jsx(Ye,{blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:s,selectedBlockIds:o.blockIds,deltaCol:m,deltaRow:d,isOutside:o.isOutside??!1,currentMousePx:o.currentMousePx,selectionStyle:i,ghostZIndex:a,selectBorderZIndex:l,blockHandlesZIndex:c});case nt.RESIZE:{const f=o.blockIds[0];return!f||!o.handle?null:r.jsx(Xe,{blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:s,blockId:f,handle:o.handle,deltaCol:m,deltaRow:d,isOutside:o.isOutside??!1,selectionStyle:i,ghostZIndex:a,selectBorderZIndex:l,blockHandlesZIndex:c})}case nt.INSERT:return o.defaultSize?r.jsx(ze,{pluginRegistry:e,gridLength:n,getBlockRectPx:s,currentGrid:o.currentGrid,currentMousePx:o.currentMousePx,pluginKind:o.pluginKind||"",defaultSize:o.defaultSize,isOutside:o.isOutside??!1,selectionStyle:i,ghostZIndex:a,selectBorderZIndex:l,blockHandlesZIndex:c}):null;default:return null}});qe.displayName="DragLayer";const ls=({id:t,plugin:e,props:n,value:o,onChange:s,onBlur:i,blockRectPx:a,zIndex:l=G.EDIT_BLOCK,validationState:c,className:m=""},d)=>{const f=u.useRef(null);u.useImperativeHandle(d,()=>({focus:()=>{var p;(p=f.current)==null||p.focus()}}),[]);const v=Ve(a,{zIndex:l,pointerEvents:"auto"}),g={width:a.width,height:a.height},E={id:t,props:n,value:o,onChange:s,onBlur:i,readOnly:!1,mode:it.FORM,dimensions:{widthPx:g.width,heightPx:g.height},validationState:c},y=e.Renderer;return r.jsx("div",{className:m,style:v,"data-testid":"editing-block","data-block-id":t,"data-plugin-kind":e.kind,children:r.jsx(y,{ref:f,...E})})},cs=u.forwardRef(ls),qn=u.memo(cs);function Kn(t){const[e,n]=u.useState({editingBlockId:null,...t}),o=u.useCallback(s=>{n(i=>{switch(s.type){case H.START_PRESS:{const a=s.selectedBlockIds||[s.blockId];return{...i,dragging:{type:nt.MOVE,blockIds:a,startGrid:s.startGrid,currentGrid:s.startGrid,isOutside:!1}}}case H.UPDATE_DRAG:return i.dragging?{...i,dragging:{...i.dragging,currentGrid:s.currentGrid,currentMousePx:s.currentMousePx,isOutside:s.isOutside??!1}}:i;case H.END_DRAG:return{...i,dragging:void 0};case H.CANCEL_DRAG:return{...i,dragging:void 0};case H.EDIT:return{...i,editingBlockId:s.blockId};case H.END_EDIT:return{...i,editingBlockId:null};case H.START_INSERT:return{...i,dragging:{type:nt.INSERT,blockIds:[],startGrid:{col:0,row:0},currentGrid:{col:0,row:0},pluginKind:s.pluginKind,defaultSize:s.defaultSize,isOutside:!1}};case H.CANCEL_INSERT:return{...i,dragging:void 0};case H.START_RESIZE:return{...i,dragging:{type:nt.RESIZE,blockIds:[s.blockId],startGrid:s.startGrid,currentGrid:s.startGrid,handle:s.handle,isOutside:!1}};default:return i}})},[]);return[e,o]}const Ke=u.memo(({blocks:t,selectedBlockIds:e,isDragging:n,draggingState:o,getBlockRectPx:s,onResizeStart:i,selectionStyle:a=Xt,handleStyle:l=fe,selectBorderZIndex:c=Z.select_border,blockHandlesZIndex:m=Z.block_handles})=>{if(n&&(o==null?void 0:o.type)!==nt.RESIZE)return null;const f=Array.from(new Set(e));return r.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:f.map(v=>{const g=t.find(p=>p.id===v);if(!g)return null;const y=(o==null?void 0:o.type)===nt.RESIZE&&o.blockIds.includes(v)?o==null?void 0:o.handle:null;return r.jsx(Lt,{block:g,rect:s(g),showHandles:!0,onResizeStart:(p,x)=>i(p,x,v),activeHandle:y,selectionStyle:a,handleStyle:l,selectBorderZIndex:c,blockHandlesZIndex:m},g.id)})})});Ke.displayName="SelectionLayer";function Zn(t,e,n,o){const s=n-e.w,i=o-e.h;return{x:Math.max(0,Math.min(t.x,s)),y:Math.max(0,Math.min(t.y,i))}}function Pe(t,e,n){const{x:o,y:s}=t;for(let i=e.length-1;i>=0;i--){const a=e[i];if(!a)continue;const l=n(a);if(o>=l.left&&o<=l.left+l.width&&s>=l.top&&s<=l.top+l.height)return a.id}return null}const Ze=u.memo(({blocks:t,pluginRegistry:e,gridLength:n,getBlockRectPx:o,getColIndex:s,getRowIndex:i,state:a,onChange:l,selectedBlockIds:c,onSelectionChange:m,onBlockChange:d,scale:f=1,className:v="",selectionStyle:g,handleStyle:E,editBlockZIndex:y=G.EDIT_BLOCK,selectBorderZIndex:p=Z.select_border,blockHandlesZIndex:x=Z.block_handles,dragGhostZIndex:h=Z.block_ghost})=>{const w=u.useRef(null),N=u.useRef(null),I=ae(a);u.useEffect(()=>{I===lt.EDITING&&a.editingBlockId&&setTimeout(()=>{var D;(D=N.current)==null||D.focus()},0)},[I,a.editingBlockId]),u.useEffect(()=>{const D=new Set(t.map(C=>C.id)),k=c.filter(C=>D.has(C));k.length!==c.length&&m(k)},[t,c,m]);const B=u.useCallback(D=>{var O;if(D.button!==0)return;const k=(O=w.current)==null?void 0:O.getBoundingClientRect();if(!k)return;const C=f??1,j={x:(D.clientX-k.left)/C,y:(D.clientY-k.top)/C},_=Pe(j,t,o);if(I===lt.EDITING){_!==a.editingBlockId&&(l({type:H.END_EDIT}),_||m([]));return}const R=s(j.x),T=i(j.y);if(_){D.stopPropagation();const U=c.includes(_);if(U&&D.shiftKey){const F=c.filter(b=>b!==_);m(F);return}else U?(D.currentTarget.setPointerCapture(D.pointerId),l({type:H.START_PRESS,blockId:_,startGrid:{col:R,row:T},selectedBlockIds:c})):(D.currentTarget.setPointerCapture(D.pointerId),D.shiftKey?m([...c,_]):(m([_]),l({type:H.START_PRESS,blockId:_,startGrid:{col:R,row:T},selectedBlockIds:[_]})))}else D.stopPropagation(),m([])},[t,o,s,i,I,c,m,l,f,a.editingBlockId]),$=u.useCallback(D=>{var P;if(I!==lt.PRESSING&&I!==lt.DRAGGING||!a.dragging)return;const k=(P=w.current)==null?void 0:P.getBoundingClientRect();if(!k)return;const C=f??1,j=k.width/C,_=k.height/C,R=(D.clientX-k.left)/C,T=(D.clientY-k.top)/C,O=a.dragging.type!==nt.RESIZE&&(R<0||R>j||T<0||T>_),U=Math.max(0,Math.min(R,j)),F=Math.max(0,Math.min(T,_)),b=s(U),M=i(F);l({type:H.UPDATE_DRAG,currentGrid:{col:b,row:M},currentMousePx:{x:R,y:T},isOutside:O})},[I,a.dragging,s,i,l,f]),A=u.useCallback(D=>{if(I===lt.DRAGGING&&a.dragging){if(a.dragging.isOutside){a.dragging.type===nt.MOVE&&(d==null||d({type:ct.DELETE,blockIds:a.dragging.blockIds}),m([])),l({type:H.END_DRAG}),D.currentTarget.releasePointerCapture(D.pointerId);return}const k=a.dragging.currentGrid.col-a.dragging.startGrid.col,C=a.dragging.currentGrid.row-a.dragging.startGrid.row;if(a.dragging.type===nt.MOVE){if(k!==0||C!==0){const j=a.dragging.blockIds.map(T=>t.find(O=>O.id===T)).filter(Boolean);if(j.length===0){l({type:H.END_DRAG}),D.currentTarget.releasePointerCapture(D.pointerId);return}const _=We(j,k,C,n.cols,n.rows),R=j.map(T=>{const O=_.find(U=>U.blockId===T.id);return O?{...T,layout:{...T.layout,x:O.x,y:O.y}}:T});d==null||d({type:ct.MOVE,blockIds:a.dragging.blockIds,blocks:R})}}else if(a.dragging.type===nt.INSERT){const{pluginKind:j,currentGrid:_,defaultSize:R}=a.dragging;if(j&&R){const T=e[j];if(T){const{x:O,y:U}=Zn({x:_.col,y:_.row},{w:R.w,h:R.h},n.cols,n.rows),F=Nt(T,{x:O,y:U,w:R.w,h:R.h});d==null||d({type:ct.ADD,blockIds:[F.id],blocks:[F]})}}}else if(a.dragging.type===nt.RESIZE){const j=a.dragging.blockIds[0],_=t.find(T=>T.id===j),R=a.dragging.handle;if(_&&R&&(k!==0||C!==0)){const T=He({layout:_.layout,handle:R,deltaCol:k,deltaRow:C,gridCols:n.cols,gridRows:n.rows});(T.x!==_.layout.x||T.y!==_.layout.y||T.w!==_.layout.w||T.h!==_.layout.h)&&(d==null||d({type:ct.RESIZE,blockIds:[_.id],blocks:[{..._,layout:T}]}))}}l({type:H.END_DRAG})}else I===lt.PRESSING&&a.dragging&&(a.dragging.isOutside&&a.dragging.type===nt.MOVE&&(d==null||d({type:ct.DELETE,blockIds:a.dragging.blockIds}),m([])),l({type:H.CANCEL_DRAG}));D.currentTarget.releasePointerCapture(D.pointerId)},[I,a.dragging,t,n,e,d,l,m]),L=u.useCallback(D=>{var R;const k=(R=w.current)==null?void 0:R.getBoundingClientRect();if(!k)return;const C=f??1,j={x:(D.clientX-k.left)/C,y:(D.clientY-k.top)/C},_=Pe(j,t,o);_&&(c.includes(_)||m([_]),l({type:H.EDIT,blockId:_}))},[t,o,l,m,f,c]),S=u.useCallback(D=>{var k;if((I===lt.PRESSING||I===lt.DRAGGING)&&a.dragging){const C=(k=w.current)==null?void 0:k.getBoundingClientRect();if(C){const j=f??1,_=(D.clientX-C.left)/j,R=(D.clientY-C.top)/j,T=C.width/j,O=C.height/j,U=Math.max(0,Math.min(_,T)),F=Math.max(0,Math.min(R,O));l({type:H.UPDATE_DRAG,currentGrid:{col:s(U),row:i(F)},currentMousePx:{x:_,y:R},isOutside:!0})}}},[I,a.dragging,f,s,i,l]);return r.jsxs("div",{ref:w,className:v,style:{position:"absolute",inset:0,zIndex:G.INTERACTION_LAYER_BASE,pointerEvents:"auto",touchAction:"none"},role:"application","aria-label":"Interactive canvas layer",tabIndex:-1,onPointerDown:B,onPointerMove:$,onPointerUp:A,onPointerLeave:S,onDoubleClick:L,"data-testid":"interaction-layer",children:[a.editingBlockId&&(()=>{const D=t.find(C=>C.id===a.editingBlockId),k=D?e[D.kind]:null;return!D||!k?null:r.jsx(qn,{ref:N,id:D.id,plugin:k,props:D.props,value:D.initValue,onChange:C=>{d==null||d({type:ct.UPDATE,blockIds:[D.id],blocks:[{...D,initValue:C}]})},onBlur:C=>{d==null||d({type:ct.UPDATE,blockIds:[D.id],blocks:[{...D,initValue:C}]})},blockRectPx:o(D),zIndex:y})})(),r.jsx(Ke,{blocks:t,selectedBlockIds:c,isDragging:I===lt.DRAGGING,draggingState:a.dragging,getBlockRectPx:o,onResizeStart:(D,k,C)=>{var T;const j=(T=w.current)==null?void 0:T.getBoundingClientRect();if(!j)return;I===lt.EDITING&&l({type:H.END_EDIT}),D.currentTarget.setPointerCapture(D.pointerId);const _=f??1,R={x:(D.clientX-j.left)/_,y:(D.clientY-j.top)/_};l({type:H.START_RESIZE,blockId:C,handle:k,startGrid:{col:s(R.x),row:i(R.y)}})},selectionStyle:g,handleStyle:E,selectBorderZIndex:p,blockHandlesZIndex:x}),r.jsx(qe,{blocks:t,pluginRegistry:e,gridLength:n,draggingState:a.dragging,getBlockRectPx:o,selectionStyle:g,ghostZIndex:h,selectBorderZIndex:p,blockHandlesZIndex:x})]})});Ze.displayName="InteractionLayer";function qt(t,e,n=W){const o=u.useMemo(()=>Y.fromDim(t.size.width),[t.size.width]),s=u.useMemo(()=>Y.fromDim(t.size.height),[t.size.height]),i=u.useMemo(()=>Y.fromDim(t.margin.top),[t.margin.top]),a=u.useMemo(()=>Y.fromDim(t.margin.bottom),[t.margin.bottom]),l=u.useMemo(()=>Y.fromDim(t.margin.left),[t.margin.left]),c=u.useMemo(()=>Y.fromDim(t.margin.right),[t.margin.right]),m=u.useMemo(()=>o-l-c,[o,l,c]),d=u.useMemo(()=>s-i-a,[s,i,a]),f=u.useMemo(()=>oe(e.cols,m),[e.cols,m]),v=u.useMemo(()=>oe(e.rows,d),[e.rows,d]),g=u.useMemo(()=>V.fromMm(o,n),[o,n]),E=u.useMemo(()=>V.fromMm(s,n),[s,n]),y=u.useMemo(()=>V.fromMm(i,n),[i,n]),p=u.useMemo(()=>V.fromMm(a,n),[a,n]),x=u.useMemo(()=>V.fromMm(l,n),[l,n]),h=u.useMemo(()=>V.fromMm(c,n),[c,n]),w=u.useMemo(()=>V.fromMm(m,n),[m,n]),N=u.useMemo(()=>V.fromMm(d,n),[d,n]),I=u.useMemo(()=>se(f,n),[f,n]),B=u.useMemo(()=>se(v,n),[v,n]),$=u.useMemo(()=>{const P=[0];for(const z of I){const ht=P[P.length-1]??0;P.push(ht+z)}return P},[I]),A=u.useMemo(()=>{const P=[0];for(const z of B){const ht=P[P.length-1]??0;P.push(ht+z)}return P},[B]),{step:L,windowPx:S}=u.useMemo(()=>Ie($),[$]),{step:D,windowPx:k}=u.useMemo(()=>Ie(A),[A]),C=u.useMemo(()=>De($,L,S),[$,L,S]),j=u.useMemo(()=>De(A,D,k),[A,D,k]),_=u.useCallback(P=>C(P-x),[C,x]),R=u.useCallback(P=>j(P-y),[j,y]),T=u.useMemo(()=>({cols:$,rows:A}),[$,A]),O=u.useMemo(()=>({width:g,height:E}),[g,E]),U=u.useMemo(()=>({top:y,bottom:p,left:x,right:h}),[y,p,x,h]),F=u.useMemo(()=>({width:w,height:N}),[w,N]),b=u.useMemo(()=>({canvas:O,margin:U,content:F}),[O,U,F]),M=u.useCallback(P=>{const{x:z,y:ht,w:Ot,h:q}=P.layout,ut=T.cols,bt=T.rows;if(!ut.length||!bt.length)return{left:0,top:0,width:0,height:0};const Kt=Math.min(Math.max(0,z),ut.length-1),hr=Math.min(Math.max(0,z+Ot),ut.length-1),ln=Math.min(Math.max(0,ht),bt.length-1),fr=Math.min(Math.max(0,ht+q),bt.length-1),pr=(ut[Kt]??0)+x,xr=(bt[ln]??0)+y,vr=(ut[hr]??0)-(ut[Kt]??0),br=(bt[fr]??0)-(bt[ln]??0);return{left:pr,top:xr,width:vr,height:br}},[T,x,y]);return{paperPx:b,gridPosPx:T,getColIndex:_,getRowIndex:R,getBlockRectPx:M}}const Jn=({schema:t,values:e,pluginRegistry:n,onValueChange:o,scale:s=1,className:i})=>{const{paperPx:a,gridPosPx:l,getBlockRectPx:c}=qt(t.paper,t.grid,W),m=u.useCallback((d,f)=>{o&&o(d,f)},[o]);return r.jsxs("div",{className:i,style:{position:"relative",width:`${a.canvas.width}px`,height:`${a.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(he,{paperPx:a,gridPosPxs:l,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(St,{blocks:t.blocks,pluginRegistry:n,mode:it.EDIT,values:e,getBlockRectPx:c,onValueChange:m,showGuides:!0,showBorder:!0})]})};Jn.displayName="NoteEdit";const Qn=u.memo(Jn),tr=({schema:t,pluginRegistry:e,onSchemaChange:n,onSelectionChange:o,scale:s=1,className:i})=>{const[a,l]=u.useState([]),[c,m]=Kn(),d=u.useRef(null),{paperPx:f,gridPosPx:v,getBlockRectPx:g,getColIndex:E,getRowIndex:y}=qt(t.paper,t.grid,W),p=u.useCallback($=>{if(n)switch($.type){case ct.MOVE:case ct.RESIZE:{if(!$.blocks)return;const A=t.blocks.map(L=>{var D;return((D=$.blocks)==null?void 0:D.find(k=>k.id===L.id))||L});n({...t,blocks:A});break}case ct.ADD:{if(!$.blocks)return;n({...t,blocks:[...t.blocks,...$.blocks]});break}case ct.DELETE:{const A=new Set($.blockIds),L=t.blocks.filter(S=>!A.has(S.id));n({...t,blocks:L});break}case ct.UPDATE:{if(!$.blocks)return;const A=t.blocks.map(L=>{var C;const S=(C=$.blocks)==null?void 0:C.find(j=>j.id===L.id);if(!S)return L;const D=S.style?ie(S.style):S.style,k=S.props?ie(S.props):S.props;return{...L,...S,style:D,props:k}});n({...t,blocks:A});break}}},[t,n]),x=u.useCallback(($,A)=>{if(!n)return;const L=t.blocks.map(S=>S.id===$?{...S,initValue:A}:S);n({...t,blocks:L})},[t,n]);u.useEffect(()=>{o&&o(a)},[a,o]),u.useEffect(()=>{const $=zt.subscribe(A=>{var S;const L=ae(c);!A&&L===lt.DRAGGING&&((S=c.dragging)==null?void 0:S.type)===nt.INSERT&&m({type:H.CANCEL_INSERT})});return()=>$()},[c,m]),u.useEffect(()=>{const $=A=>{if(a.length===0)return;const L=A.target;L instanceof HTMLElement&&L.closest('[data-sidebar="true"]')||d.current&&!d.current.contains(L)&&l([])};return document.addEventListener("mousedown",$),()=>{document.removeEventListener("mousedown",$)}},[a]);const h=u.useCallback(($,A,L)=>{if(!n)return;const S=A-1;if($==="column"){const D=Ne(t.grid.cols,S,L,f.content.width);n({...t,grid:{...t.grid,cols:D}})}else{const D=Ne(t.grid.rows,S,L,f.content.height);n({...t,grid:{...t.grid,rows:D}})}},[t,f,n]),w=u.useCallback(($,A,L)=>{if(n)if($==="column"){const S=[...t.grid.cols];S[A]=L,n({...t,grid:{...t.grid,cols:S}})}else{const S=[...t.grid.rows];S[A]=L,n({...t,grid:{...t.grid,rows:S}})}},[n,t]),N=u.useMemo(()=>t.blocks.reduce(($,A)=>($[A.id]=A.initValue,$),{}),[t.blocks]),I=u.useCallback(()=>{const $=zt.get();!$||ae(c)===lt.DRAGGING||c.dragging||m({type:H.START_INSERT,pluginKind:$.kind,defaultSize:$.defaultSize})},[c,m]),B=u.useCallback(()=>{},[]);return r.jsxs("div",{ref:d,className:i,onPointerEnter:I,onPointerLeave:B,style:{position:"relative",width:`${f.canvas.width}px`,height:`${f.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(he,{paperPx:f,gridPosPxs:v,gridDimensions:{cols:t.grid.cols,rows:t.grid.rows},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:h,onDimensionChange:w,gridLineStyle:{color:"#e5e7eb",width:{value:1,unit:"px"},type:dt.SOLID},borderStyle:{all:{color:"#000000",width:{value:1,unit:"px"},type:dt.SOLID}}}),r.jsx(St,{blocks:t.blocks,pluginRegistry:e,mode:it.FORM,values:N,selectedBlockIds:a,getBlockRectPx:g,onValueChange:x,showGuides:!0,showBorder:!0}),r.jsx(Ze,{blocks:t.blocks,gridLength:{cols:t.grid.cols.length,rows:t.grid.rows.length},pluginRegistry:e,getBlockRectPx:g,getColIndex:E,getRowIndex:y,selectedBlockIds:a,onSelectionChange:l,state:c,onChange:m,onBlockChange:p,scale:s})]})};tr.displayName="NoteForm";const er=u.memo(tr),nr=({schema:t,values:e,pluginRegistry:n,scale:o=1,className:s})=>{const{paperPx:i,gridPosPx:a,getBlockRectPx:l}=qt(t.paper,t.grid,W);return r.jsxs("div",{className:s,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(he,{paperPx:i,gridPosPxs:a,showGridLines:!1,showMargins:!1,showBorder:!1}),r.jsx(St,{blocks:t.blocks,pluginRegistry:n,mode:it.VIEW,values:e,getBlockRectPx:l,showGuides:!1,showBorder:!0})]})};nr.displayName="NoteView";const rr=u.memo(nr),or=({schema:t,values:e,mode:n,pluginRegistry:o,onSchemaChange:s,onValuesChange:i,onSelectionChange:a,scale:l=1,className:c})=>{const m=u.useCallback((d,f)=>{if(i)if(f==null){const{[d]:v,...g}=e;i(g)}else i({...e,[d]:f})},[e,i]);return n===it.FORM?r.jsx(er,{schema:t,pluginRegistry:o,onSchemaChange:s,onSelectionChange:a,scale:l,className:c}):n===it.EDIT?r.jsx(Qn,{schema:t,values:e,pluginRegistry:o,onValueChange:m,scale:l,className:c}):r.jsx(rr,{schema:t,values:e,pluginRegistry:o,scale:l,className:c})};or.displayName="NoteEditor";const us=u.memo(or),sr=({schema:t,values:e,pluginRegistry:n,className:o},s)=>{const i=u.useRef(null),{paperPx:a,getBlockRectPx:l}=qt(t.paper,t.grid,W);return u.useEffect(()=>{const{size:c}=t.paper,m=Y.fromDim(c.width),d=Y.fromDim(c.height),f=document.getElementById("printable-note-page-style");f&&f.remove();const v=document.createElement("style");return v.id="printable-note-page-style",v.textContent=`
|
|
63
63
|
@media print {
|
|
64
64
|
@page {
|
|
65
|
-
size: ${
|
|
65
|
+
size: ${m}mm ${d}mm;
|
|
66
66
|
margin: 0;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
`,document.head.appendChild(g),()=>{const b=document.getElementById("printable-note-page-style");b&&b.remove()}},[e.paper]),u.useImperativeHandle(o,()=>({print:()=>{a.current&&Dt(a.current,{title:"Document"})},openPrintPreview:()=>{a.current&&Dt(a.current,{title:"Document"})}}),[]),r.jsx("div",{ref:a,className:s,style:{width:`${i.canvas.width}px`,height:`${i.canvas.height}px`,backgroundColor:"#fff",paddingTop:`${i.margin.top}px`,paddingLeft:`${i.margin.left}px`,paddingRight:`${i.margin.right}px`,paddingBottom:`${i.margin.bottom}px`,boxSizing:"border-box"},children:r.jsx("div",{style:{position:"relative",width:`${i.content.width}px`,height:`${i.content.height}px`},children:r.jsx(Se,{blocks:e.blocks,pluginRegistry:n,mode:ae.VIEW,values:t??{},getBlockRectPx:l,showGuides:!1,showBorder:!0})})})};or.displayName="NotePrint";const us=u.memo(u.forwardRef(or));function ge(e,t){if(e.length===0)return;const n=(i,l)=>{let c=i;for(const d of l){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 ds="_container_1nwxd_1",ms="_row_1nwxd_39",hs="_inputWrapper_1nwxd_73",wt={container:ds,row:ms,inputWrapper:hs},sr=({selectedBlocks:e,onUpdateBlocks:t})=>{if(e.length===0)return null;const n=s=>{const o={};e.forEach(a=>{o[a.id]={style:{...a.style,backgroundColor:s}}}),t(o)};return r.jsx("div",{className:wt.container,children:r.jsx("div",{className:wt.row,children:r.jsx("div",{className:wt.inputWrapper,children:r.jsx(We,{value:ge(e,"style.backgroundColor"),onChange:n,allowUndefined:!0,placeholder:"無色",height:24})})})})};function we(e,t,n){const s=t.split("."),o=(a,i)=>{const l=s[i];if(i===s.length-1){if(n==null){const{[l]:m,...x}=a;return x}return{...a,[l]:n}}const c=(a==null?void 0:a[l])||{},d=o(c,i+1);if(Object.keys(d).length===0){const{[l]:m,...x}=a;return x}return{...a,[l]:d}};return o(e,0)}const ir=({selectedBlocks:e,onUpdateBlocks:t})=>{const n=(i,l,c)=>{const d={};e.forEach(m=>{var g,b,j;let x=we(m.style||{},`border.${i}.${l}`,c);if(l==="type"&&c==null&&(x=we(x,`border.${i}.width`,void 0),x=we(x,`border.${i}.color`,void 0)),l==="type"&&c!==void 0&&c!==null){const y=(g=m.style)==null?void 0:g.border,f=y==null?void 0:y[i];f!=null&&f.width||(x=we(x,`border.${i}.width`,{value:1,unit:"px"})),f!=null&&f.color||(x=we(x,`border.${i}.color`,"#000000"))}if(l==="color"&&c!==void 0&&c!==null){const y=(b=m.style)==null?void 0:b.border,f=y==null?void 0:y[i];f!=null&&f.type||(x=we(x,`border.${i}.type`,de.SOLID)),f!=null&&f.width||(x=we(x,`border.${i}.width`,{value:1,unit:"px"}))}if(l==="width"&&c!==void 0&&c!==null){const y=(j=m.style)==null?void 0:j.border,f=y==null?void 0:y[i];f!=null&&f.type||(x=we(x,`border.${i}.type`,de.SOLID)),f!=null&&f.color||(x=we(x,`border.${i}.color`,"#000000"))}d[m.id]={style:x}}),t(d)},s=u.useMemo(()=>{var m;if(e.length!==1)return null;const i=e[0];if(!((m=i==null?void 0:i.style)!=null&&m.border))return null;const l=i.style.border;if(!l)return null;const c=x=>x?!(x.type&&!x.width):!0;return["all","top","right","bottom","left"].every(x=>c(l[x]))?new Ae(l):null},[e]),o=i=>r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx(_e,{value:ge(e,`style.border.${i}.type`),onChange:l=>n(i,"type",l),placeholder:"スタイル",height:24,options:[{label:"",value:void 0},{label:"実線",value:de.SOLID},{label:"破線",value:de.DASHED},{label:"点線",value:de.DOTTED}]}),r.jsx(oe,{value:ge(e,`style.border.${i}.width`),onChange:l=>n(i,"width",l),placeholder:"太さ",height:24,allowedUnits:gn,min:1}),r.jsx(We,{value:ge(e,`style.border.${i}.color`),onChange:l=>n(i,"color",l),placeholder:"色",height:24,allowUndefined:!0})]}),a={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(Ie,{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:a,children:"共通"}),r.jsx(ye,{value:"top",height:24,style:a,children:"上"}),r.jsx(ye,{value:"bottom",height:24,style:a,children:"下"}),r.jsx(ye,{value:"left",height:24,style:a,children:"左"}),r.jsx(ye,{value:"right",height:24,style:a,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")})]})]})})]})},fs="_container_2914u_1",ps="_grid_2914u_37",xs="_field_2914u_51",gs="_label_2914u_65",bs="_inputWrapper_2914u_85",le={container:fs,grid:ps,field:xs,label:gs,inputWrapper:bs},ar=({selectedBlocks:e,onUpdateBlocks:t,gridSize:n})=>{if(e.length===0)return null;const s=e.length>1,o=s?Math.min(...e.map(l=>l.layout.x)):void 0,a=s?Math.min(...e.map(l=>l.layout.y)):void 0,i=(l,c)=>{if(c===void 0)return;const d={};if(s&&(l==="x"||l==="y")){const m=l==="x"?o:a;if(m===void 0)return;const x=Math.max(...e.map(p=>p.layout.x+p.layout.w)),g=Math.max(...e.map(p=>p.layout.y+p.layout.h)),b=x-(o??0),j=g-(a??0);let y=c;l==="x"&&n?y=Math.max(0,Math.min(c,n.cols-b)):l==="y"&&n?y=Math.max(0,Math.min(c,n.rows-j)):y=Math.max(0,c);const f=y-m;e.forEach(p=>{const h=p.layout[l]+f;d[p.id]={layout:{...p.layout,[l]:h}}})}else e.forEach(m=>{let x=c;if(l==="x"&&n)x=Math.max(0,Math.min(c,n.cols-m.layout.w));else if(l==="y"&&n)x=Math.max(0,Math.min(c,n.rows-m.layout.h));else if(l==="w"&&n){const g=n.cols-m.layout.x;x=Math.max(1,Math.min(c,g))}else if(l==="h"&&n){const g=n.rows-m.layout.y;x=Math.max(1,Math.min(c,g))}else l==="w"||l==="h"?x=Math.max(1,c):x=Math.max(0,c);d[m.id]={layout:{...m.layout,[l]: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:ge(e,"layout.x"),onChange:l=>i("x",l),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?a:ge(e,"layout.y"),onChange:l=>i("y",l),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:ge(e,"layout.w"),onChange:l=>i("w",l),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:ge(e,"layout.h"),onChange:l=>i("h",l),min:1,max:n==null?void 0:n.rows,integer:!0,height:22,placeholder:"-"})})]})]})})},vs="_container_razoq_1",_s="_row_razoq_19",ws="_label_razoq_31",ys="_inputWrapper_razoq_49",De={container:vs,row:_s,label:ws,inputWrapper:ys},lr=({selectedBlocks:e,onUpdateBlocks:t})=>{const[n,s]=u.useState(""),o=e[0];u.useEffect(()=>{e.length===1&&o&&s(o.id)},[e,o]);const a=()=>{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??"")},l=c=>{const d={};e.forEach(m=>{d[m.id]={behavior:{...m.behavior,readOnly:!!c}}}),t(d)};return r.jsxs("div",{className:De.container,children:[e.length===1&&r.jsxs("div",{className:De.row,children:[r.jsx("span",{className:De.label,children:"ID"}),r.jsx("div",{className:De.inputWrapper,children:r.jsx(Pe,{value:n,onChange:i,onBlur:a,placeholder:"IDを入力",height:16})})]}),e.length>0&&r.jsx("div",{className:De.row,children:r.jsx("div",{className:De.inputWrapper,children:r.jsx(xe,{label:"読み取り専用",value:!!ge(e,"behavior.readOnly"),onChange:l})})})]})},Es="_container_1axrl_1",js="_scrollArea_1axrl_35",Ns="_section_1axrl_51",Is="_sectionTitle_1axrl_69",Ds="_subsection_1axrl_93",$s="_subsectionTitle_1axrl_101",Ts="_fields_1axrl_117",Cs="_emptyState_1axrl_137",se={container:Es,scrollArea:js,section:Ns,sectionTitle:Is,subsection:Ds,subsectionTitle:$s,fields:Ts,emptyState:Cs},Rs="_field_1f6zx_1",Ms="_label_1f6zx_13",ks="_mixed_1f6zx_29",Ps="_description_1f6zx_43",Qe={field:Rs,label:Ms,mixed:ks,description:Ps},ft=u.memo(({propertyKey:e,definition:t,selectedBlocks:n,onChange:s})=>{var m;const o=t.Component;if(!o)return null;const a=ge(n,`props.${e}`),c=!n.map(x=>x.props[e]).every(x=>x===void 0)&&a===void 0&&n.length>1,d={value:c?void 0:a!==void 0?a:t.defaultValue,onChange:x=>s(e,x),readOnly:!1,config:{...t.config,placeholder:c?"複数選択中 (値が異なります)":(m=t.config)==null?void 0:m.placeholder}};return r.jsxs("div",{className:Qe.field,children:[t.label&&r.jsx("div",{className:Qe.label,title:t.description,children:t.label}),r.jsx(o,{...d}),c&&r.jsx("span",{className:Qe.mixed,children:"(混在)"}),t.description&&r.jsx("p",{className:Qe.description,children:t.description})]})});ft.displayName="PropertyField";function As(e){return e!==!1}const qt=u.memo(({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n,gridSize:s,className:o=""})=>{const a=e[0],i=a?t[a.kind]:void 0,l=u.useMemo(()=>{var x;if(e.length===0)return!1;const m=(x=e[0])==null?void 0:x.kind;return e.every(g=>g.kind===m)},[e]),c=u.useMemo(()=>{if(!a||!i)return{};const m={};let x;if(l)x=Object.entries(i.properties);else{const g=e.map(f=>t[f.kind]).filter(f=>f!==void 0);if(g.length===0)return{};const b=g[0];if(!b)return{};const j=new Set(Object.keys(b.properties));x=Array.from(j).filter(f=>g.every(p=>f in p.properties)).map(f=>{const p=i.properties[f];return p?[f,p]:null}).filter(f=>f!==null)}return x.forEach(([g,b])=>{if(!As(b)||e.length>1&&b.disableInMultiSelection||b.condition&&!b.condition(a.props))return;const j=b.group||"基本";m[j]||(m[j]=[]),b.Component&&m[j].push({key:g,definition:b})}),m},[i,t,e,a,l]),d=(m,x)=>{const g={};e.forEach(b=>{g[b.id]={props:{...b.props,[m]:x}}}),n(g)};return e.length===0?r.jsx("div",{className:`${se.container} ${o}`,children:r.jsxs("div",{className:se.emptyState,children:["ブロックを選択すると",r.jsx("br",{}),"プロパティが表示されます"]})}):r.jsx("div",{className:`${se.container} ${o}`,children:r.jsxs("div",{className:se.scrollArea,children:[r.jsxs("div",{className:se.section,children:[r.jsx("div",{className:se.sectionTitle,children:"配置・サイズ"}),r.jsx(ar,{selectedBlocks:e,onUpdateBlocks:n,gridSize:s})]}),r.jsxs("div",{className:se.section,children:[r.jsx("div",{className:se.sectionTitle,children:"背景"}),r.jsx(sr,{selectedBlocks:e,onUpdateBlocks:n})]}),r.jsxs("div",{className:se.section,children:[r.jsx("div",{className:se.sectionTitle,children:"枠線"}),r.jsx(ir,{selectedBlocks:e,onUpdateBlocks:n})]}),i&&Object.keys(c).length>0&&r.jsx("div",{className:se.section,children:Object.entries(c).map(([m,x])=>r.jsxs("div",{className:se.subsection,children:[r.jsx("div",{className:se.subsectionTitle,children:m}),r.jsx("div",{className:se.fields,children:x.map(({key:g,definition:b})=>r.jsx(ft,{propertyKey:g,definition:b,selectedBlocks:e,onChange:d},g))})]},m))}),r.jsxs("div",{className:se.section,children:[r.jsx("div",{className:se.sectionTitle,children:"基本設定"}),r.jsx(lr,{selectedBlocks:e,onUpdateBlocks:n})]})]})})});qt.displayName="BlockPropertyPanel";const Ss="_panel_4e5h0_1",Ls="_header_4e5h0_21",Os="_group_4e5h0_35",Gs="_groupTitle_4e5h0_51",Bs="_groupContent_4e5h0_71",Ve={panel:Ss,header:Ls,group:Os,groupTitle:Gs,groupContent:Bs};function Vs(e){return e!==!1}const Us=({selectedBlocks:e,pluginRegistry:t,onUpdateBlocks:n})=>{const s=e[0],o=s?t[s.kind]:void 0,a=u.useMemo(()=>{if(!s||!o)return{};const l={};return Object.entries(o.properties).forEach(([c,d])=>{if(!Vs(d)||e.length>1&&d.disableInMultiSelection||d.condition&&!d.condition(s.props))return;const m=d.group||"基本";l[m]||(l[m]=[]),d.Component&&l[m].push({key:c,definition:d})}),l},[o,e.length,s]),i=(l,c)=>{const d={};e.forEach(m=>{d[m.id]={props:{...m.props,[l]: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(a).map(([l,c])=>r.jsxs("div",{className:Ve.group,children:[r.jsx("div",{className:Ve.groupTitle,children:l}),r.jsx("div",{className:Ve.groupContent,children:c.map(({key:d,definition:m})=>r.jsx(ft,{propertyKey:d,definition:m,selectedBlocks:e,onChange:i},d))})]},l))]})},Fs="_panel_1p81n_11",zs="_title_1p81n_19",Ws="_content_1p81n_43",Ys="_description_1p81n_57",Hs="_list_1p81n_69",Ks="_item_1p81n_87",Xs="_dragging_1p81n_121",Zs="_dragOver_1p81n_131",qs="_dragHandle_1p81n_141",Js="_itemInfo_1p81n_171",Qs="_itemId_1p81n_185",ei="_itemMeta_1p81n_195",ti="_itemKind_1p81n_209",ni="_itemActions_1p81n_225",ri="_actionButton_1p81n_235",oi="_empty_1p81n_307",Q={panel:Fs,title:zs,content:Ws,description:Ys,list:Hs,item:Ks,dragging:Xs,dragOver:Zs,dragHandle:qs,itemInfo:Js,itemId:Qs,itemMeta:ei,itemKind:ti,itemActions:ni,actionButton:ri,empty:oi},Jt=({blocks:e,onBlocksChange:t})=>{const[n,s]=u.useState(null),[o,a]=u.useState(null),i=[...e].reverse(),l=u.useCallback(f=>{const p=e.findIndex(I=>I.id===f);if(p===-1||p===e.length-1)return;const h=[...e],[_]=h.splice(p,1);_&&(h.push(_),t(h))},[e,t]),c=u.useCallback(f=>{const p=e.findIndex(I=>I.id===f);if(p===-1||p===0)return;const h=[...e],[_]=h.splice(p,1);_&&(h.unshift(_),t(h))},[e,t]),d=u.useCallback(f=>{const p=e.findIndex(E=>E.id===f);if(p===-1||p===e.length-1)return;const h=[...e],_=h[p],I=h[p+1];!_||!I||(h[p]=I,h[p+1]=_,t(h))},[e,t]),m=u.useCallback(f=>{const p=e.findIndex(E=>E.id===f);if(p===-1||p===0)return;const h=[...e],_=h[p],I=h[p-1];!_||!I||(h[p]=I,h[p-1]=_,t(h))},[e,t]),x=u.useCallback((f,p)=>{var _;s(p),f.dataTransfer.effectAllowed="move";const h=e.length-1-p;f.currentTarget&&f.dataTransfer.setData("text/plain",((_=e[h])==null?void 0:_.id)||"")},[e]),g=u.useCallback(()=>{s(null),a(null)},[]),b=u.useCallback((f,p)=>{f.preventDefault(),f.dataTransfer.dropEffect="move",!(n===null||n===p)&&a(p)},[n]),j=u.useCallback(()=>{a(null)},[]),y=u.useCallback((f,p)=>{if(f.preventDefault(),n===null||n===p){s(null),a(null);return}const h=e.length-1-n,_=e.length-1-p,I=[...e],[E]=I.splice(h,1);E&&(I.splice(_,0,E),t(I),s(null),a(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((f,p)=>{const h=e.length-1-p;return r.jsxs("li",{className:`${Q.item} ${n===p?Q.dragging:""} ${o===p?Q.dragOver:""}`,onDragOver:_=>b(_,p),onDragLeave:j,onDrop:_=>y(_,p),children:[r.jsx("button",{type:"button",className:Q.dragHandle,title:"ドラッグして並び替え",draggable:!0,onDragStart:_=>x(_,p),onDragEnd:g,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:f.id}),r.jsx("div",{className:Q.itemMeta,children:r.jsx("span",{className:Q.itemKind,children:f.kind})})]}),r.jsxs("div",{className:Q.itemActions,children:[r.jsx("button",{type:"button",className:Q.actionButton,onClick:()=>l(f.id),title:"最前面へ","aria-label":"最前面へ移動",disabled:h===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(f.id),title:"前面へ","aria-label":"前面へ移動",disabled:h===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:()=>m(f.id),title:"背面へ","aria-label":"背面へ移動",disabled:h===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(f.id),title:"最背面へ","aria-label":"最背面へ移動",disabled:h===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"})]})})]})]},f.id)})}),e.length===0&&r.jsx("div",{className:Q.empty,children:"ブロックがありません"})]})]})};Jt.displayName="BlockOrderPanel";const Qt=({schema:e,onSchemaChange:t})=>{const n=u.useCallback(a=>{t({...e,paper:a})},[e,t]),s=u.useCallback(a=>{t({...e,grid:a})},[e,t]),o=u.useCallback(a=>{t({...e,blocks:a})},[e,t]);return r.jsxs(St,{children:[r.jsx(nn,{paper:e.paper,onPaperChange:n}),r.jsx(tn,{paper:e.paper,onPaperChange:n}),r.jsx(en,{grid:e.grid,onGridChange:s}),r.jsx(Jt,{blocks:e.blocks,onBlocksChange:o})]})};Qt.displayName="CanvasPanel";const si="_panel_98kh0_11",ii="_title_98kh0_19",ai="_content_98kh0_43",li="_field_98kh0_57",ci="_horizontal_98kh0_69",ui="_label_98kh0_81",di="_gridSizeRow_98kh0_103",ve={panel:si,title:ii,content:ai,field:li,horizontal:ci,label:ui,gridSizeRow:di},en=({grid:e,onGridChange:t})=>{const n=u.useCallback(o=>{if(!o||o<1||o>100)return;const a=e.cols.length,i=[];if(o>a){i.push(...e.cols);for(let l=a;l<o;l++)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 a=e.rows.length,i=[];if(o>a){i.push(...e.rows);for(let l=a;l<o;l++)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:ve.panel,children:[r.jsx("h3",{className:ve.title,children:"グリッドサイズ"}),r.jsx("div",{className:ve.content,children:r.jsxs("div",{className:ve.gridSizeRow,children:[r.jsxs("div",{className:`${ve.field} ${ve.horizontal}`,children:[r.jsx("span",{className:ve.label,children:"列数"}),r.jsx(ie,{value:e.cols.length,onChange:n,min:1,max:100,step:1})]}),r.jsxs("div",{className:`${ve.field} ${ve.horizontal}`,children:[r.jsx("span",{className:ve.label,children:"行数"}),r.jsx(ie,{value:e.rows.length,onChange:s,min:1,max:100,step:1})]})]})})]})};en.displayName="GridSizePanel";const mi="_panel_7447e_11",hi="_header_7447e_19",fi="_title_7447e_39",pi="_headerActions_7447e_57",xi="_content_7447e_65",gi="_field_7447e_73",bi="_horizontal_7447e_85",vi="_label_7447e_97",_i="_marginsGrid_7447e_119",wi="_topMargin_7447e_131",yi="_bottomMargin_7447e_133",Ei="_sideMargins_7447e_145",q={panel:mi,header:hi,title:fi,headerActions:pi,content:xi,field:gi,horizontal:bi,label:vi,marginsGrid:_i,topMargin:wi,bottomMargin:yi,sideMargins:Ei},tn=({paper:e,onPaperChange:t})=>{const[n,s]=u.useState(!1),o=u.useCallback(d=>{d!==void 0&&s(d)},[]),a=u.useCallback(d=>{if(!d)return;const m=n?{top:d,right:d,bottom:d,left:d}:{...e.margin,top:d};t({...e,margin:m})},[e,t,n]),i=u.useCallback(d=>{d&&t({...e,margin:{...e.margin,right:d}})},[e,t]),l=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:q.panel,children:[r.jsxs("div",{className:q.header,children:[r.jsx("h3",{className:q.title,children:"マージン"}),r.jsx("div",{className:q.headerActions,children:r.jsx(xe,{value:n,onChange:o,label:"全辺を一括設定"})})]}),r.jsx("div",{className:q.content,children:n?r.jsxs("div",{className:`${q.field} ${q.horizontal}`,children:[r.jsx("span",{className:q.label,children:"全辺"}),r.jsx(oe,{value:e.margin.top,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})]}):r.jsxs("div",{className:q.marginsGrid,children:[r.jsx("div",{className:`${q.field} ${q.horizontal} ${q.topMargin}`,children:r.jsx(oe,{value:e.margin.top,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsxs("div",{className:q.sideMargins,children:[r.jsx("div",{className:`${q.field} ${q.horizontal}`,children:r.jsx(oe,{value:e.margin.left,onChange:c,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsx("div",{className:`${q.field} ${q.horizontal}`,children:r.jsx(oe,{value:e.margin.right,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]}),r.jsx("div",{className:`${q.field} ${q.horizontal} ${q.bottomMargin}`,children:r.jsx(oe,{value:e.margin.bottom,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]})})]})};tn.displayName="MarginPanel";const ji="_panel_18o68_11",Ni="_title_18o68_19",Ii="_content_18o68_43",Di="_field_18o68_57",$i="_horizontal_18o68_69",Ti="_label_18o68_81",Ci="_dimensionsRow_18o68_103",fe={panel:ji,title:Ni,content:Ii,field:Di,horizontal:$i,label:Ti,dimensionsRow:Ci},nn=({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(l=>{if(!l)return;const c=Gt[l];t({...e,size:c})},[e,t]),o=u.useCallback(l=>{if(!l)return;const c={...e.size,preset:pe.CUSTOM,width:l};t({...e,size:c})},[e,t]),a=u.useCallback(l=>{if(!l)return;const c={...e.size,preset:pe.CUSTOM,height:l};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(_e,{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(oe,{value:e.size.width,onChange:o,allowedUnits:["mm","cm","inch"],min:e.margin.left.value+e.margin.right.value+1,max:500})]}),r.jsxs("div",{className:`${fe.field} ${fe.horizontal}`,children:[r.jsx("span",{className:fe.label,children:"高さ"}),r.jsx(oe,{value:e.size.height,onChange:a,allowedUnits:["mm","cm","inch"],min:e.margin.top.value+e.margin.bottom.value+1,max:500})]})]})]})]})};nn.displayName="PaperSizePanel";const Ri="_section_1o2ff_11",Mi="_title_1o2ff_27",ki="_content_1o2ff_51",Pi="_buttonGroup_1o2ff_65",Ai="_button_1o2ff_65",Si="_error_1o2ff_129",ee={section:Ri,title:Mi,content:ki,buttonGroup:Pi,button:Ai,error:Si},rn=({schema:e,values:t,onSchemaChange:n,onValuesChange:s})=>{const[o,a]=u.useState(""),i=u.useRef(null),l=u.useRef(null),c=u.useCallback(()=>{try{const h=Tt(e,!0),_=new Blob([h],{type:"application/json"}),I=URL.createObjectURL(_),E=document.createElement("a");E.href=I,E.download="schema.json",E.click(),URL.revokeObjectURL(I),a("")}catch(h){a(`エクスポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[e]),d=u.useCallback(async()=>{try{const h=Tt(e,!0);await navigator.clipboard.writeText(h),a(""),alert("スキーマをクリップボードにコピーしました")}catch(h){a(`クリップボードエラー: ${h instanceof Error?h.message:String(h)}`)}},[e]),m=u.useCallback(()=>{var h;(h=i.current)==null||h.click()},[]),x=u.useCallback(h=>{var E;const _=(E=h.target.files)==null?void 0:E[0];if(!_)return;const I=new FileReader;I.onload=M=>{var $;try{const w=($=M.target)==null?void 0:$.result,T=$t(w);n(T),a(""),alert("スキーマをインポートしました")}catch(w){a(`インポートエラー: ${w instanceof Error?w.message:String(w)}`)}},I.readAsText(_),h.target.value=""},[n]),g=u.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),_=$t(h);n(_),a(""),alert("スキーマをインポートしました")}catch(h){a(`インポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[n]),b=u.useCallback(()=>{try{const h=Rt(t,!0),_=new Blob([h],{type:"application/json"}),I=URL.createObjectURL(_),E=document.createElement("a");E.href=I,E.download="values.json",E.click(),URL.revokeObjectURL(I),a("")}catch(h){a(`エクスポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[t]),j=u.useCallback(async()=>{try{const h=Rt(t,!0);await navigator.clipboard.writeText(h),a(""),alert("値をクリップボードにコピーしました")}catch(h){a(`クリップボードエラー: ${h instanceof Error?h.message:String(h)}`)}},[t]),y=u.useCallback(()=>{var h;(h=l.current)==null||h.click()},[]),f=u.useCallback(h=>{var E;const _=(E=h.target.files)==null?void 0:E[0];if(!_)return;const I=new FileReader;I.onload=M=>{var $;try{const w=($=M.target)==null?void 0:$.result,T=Ct(w);s(T),a(""),alert("値をインポートしました")}catch(w){a(`インポートエラー: ${w instanceof Error?w.message:String(w)}`)}},I.readAsText(_),h.target.value=""},[s]),p=u.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),_=Ct(h);s(_),a(""),alert("値をインポートしました")}catch(h){a(`インポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[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:m,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:g,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:b,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:ee.button,onClick:j,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:l,type:"file",accept:".json",style:{display:"none"},onChange:f})]})]}),o&&r.jsx("div",{className:ee.error,role:"alert",children:o})]})};rn.displayName="ImportExportPanel";const on=({schema:e,values:t,onSchemaChange:n,onValuesChange:s})=>r.jsx(St,{children:r.jsx(rn,{schema:e,values:t,onSchemaChange:n,onValuesChange:s})});on.displayName="OtherPanel";const Li="_container_11zea_5",Oi="_paletteItems_11zea_63",Gi="_item_11zea_87",Bi="_itemName_11zea_139",Vi="_itemPreview_11zea_195",Fe={container:Li,paletteItems:Oi,item:Gi,itemName:Bi,itemPreview:Vi},sn=({plugins:e,className:t})=>{const[n,s]=u.useState(null),o=u.useCallback((a,i)=>{s({plugin:a,mousePos:i,isOverCanvas:!1});const l=d=>{const m=document.elementFromPoint(d.clientX,d.clientY),x=!!(m!=null&&m.closest('[data-testid="interaction-layer"]'));s(g=>g?{...g,mousePos:{x:d.clientX,y:d.clientY},isOverCanvas:x}:null)},c=()=>{s(null),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",c)};window.addEventListener("pointermove",l),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(a=>r.jsx(cr,{plugin:a,onDragStart:o},a.kind))})}),n&&!n.isOverCanvas&&r.jsx(ur,{plugin:n.plugin,mousePos:n.mousePos})]})};sn.displayName="PalettePanel";const cr=({plugin:e,onDragStart:t})=>{const n=u.useMemo(()=>Ne(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(a=>{a.preventDefault(),ze.start(e.kind,e.meta.defaultSize),t(e,{x:a.clientX,y:a.clientY});const i=()=>{ze.end(),window.removeEventListener("pointerup",i)};window.addEventListener("pointerup",i)},[e,t]);return r.jsxs("div",{className:Fe.item,children:[r.jsx("button",{type:"button",onPointerDown:o,className:Fe.itemName,"aria-label":`${e.meta.displayName}ブロックを追加`,children:e.meta.displayName}),r.jsx("div",{className:Fe.itemPreview,onPointerDown:o,"aria-hidden":"true",children:r.jsx(e.Renderer,{id:n.id,props:n.props,value:s,onChange:()=>{},readOnly:!0,mode:ae.FORM})})]})};cr.displayName="PaletteItem";const ur=({plugin:e,mousePos:t})=>{const n=u.useMemo(()=>Ne(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:ae.FORM})})};ur.displayName="DragGhost";const Ui="_container_k3psy_5",Fi="_tabHeader_k3psy_27",zi="_tabContent_k3psy_41",Ue={container:Ui,tabHeader:Fi,tabContent:zi},dr=({blocks:e,selectedBlockIds:t,pluginRegistry:n,onUpdateBlocks:s,schema:o,values:a,onSchemaChange:i,onValuesChange:l,gridSize:c,className:d})=>{const m=u.useMemo(()=>Object.values(n),[n]),x=u.useMemo(()=>e.filter(b=>t.includes(b.id)),[e,t]),g=t.length>0;return r.jsx("div",{className:`${Ue.container} ${d||""}`,"data-sidebar":"true",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:g?r.jsx(qt,{selectedBlocks:x,pluginRegistry:n,onUpdateBlocks:s,gridSize:c}):r.jsx(sn,{plugins:m})}),r.jsx(Ee,{value:"canvas",className:Ue.tabContent,children:r.jsx(Qt,{schema:o,onSchemaChange:i})}),r.jsx(Ee,{value:"other",className:Ue.tabContent,children:r.jsx(on,{schema:o,values:a,onSchemaChange:i,onValuesChange:l})})]})})};dr.displayName="Sidebar";exports.ACTUAL_UNITS=so;exports.ALL_UNITS=oo;exports.BLOCK_SUB_INDEX=me;exports.BORDER_UNITS=gn;exports.BackgroundPanel=sr;exports.BlockBorder=Tn;exports.BlockCanvas=Cn;exports.BlockChangeType=ce;exports.BlockContainer=Vt;exports.BlockGuideBorder=Mn;exports.BlockLayer=Se;exports.BlockOrderPanel=Jt;exports.BlockPropertyPanel=qt;exports.BlockRenderer=He;exports.Border=Ae;exports.BorderOverlay=kn;exports.BorderPanel=ir;exports.BorderRenderer=Ie;exports.COLOR_PALETTE=xn;exports.CanvasPanel=Qt;exports.Checkbox=xe;exports.ColorPalette=kt;exports.ColorPicker=We;exports.ColorPickerPopover=At;exports.DEFAULT_DPI=W;exports.DEFAULT_FONT_FAMILY=_n;exports.DEFAULT_GRID=En;exports.DEFAULT_GUIDE_BORDER=dt;exports.DEFAULT_GUIDE_LINE=Rn;exports.DEFAULT_PAPER=In;exports.DEFAULT_PAPER_MARGIN=Nn;exports.DEFAULT_PAPER_SIZES=Gt;exports.DEFAULT_SCHEMA=wo;exports.DimensionInput=oe;exports.DragLayer=Kt;exports.DragType=re;exports.EditingBlock=Kn;exports.FONT_UNITS=bn;exports.GRID_UNITS=ao;exports.GridCanvas=Pn;exports.GridDimensionLabel=tt;exports.GridLayer=mt;exports.GridOverlay=On;exports.GridResizeHandle=nt;exports.GridSizePanel=en;exports.HorizontalAlign=Te;exports.ImageObjectFit=je;exports.ImportExportPanel=rn;exports.InsertGhost=Ft;exports.InteractionBlock=Le;exports.InteractionEventType=G;exports.InteractionLayer=Zt;exports.InteractionMode=U;exports.LayoutPanel=ar;exports.LineType=de;exports.MarginOverlay=Gn;exports.MarginPanel=tn;exports.MetaPanel=lr;exports.MovingGhost=Wt;exports.MultilineWhiteSpace=Me;exports.MultilineWordWrap=Re;exports.NoteEdit=Jn;exports.NoteEditor=cs;exports.NoteForm=er;exports.NoteMode=ae;exports.NotePrint=us;exports.NoteView=nr;exports.NumberInput=ie;exports.OtherPanel=on;exports.PADDING_UNITS=$e;exports.PAPER_UNITS=io;exports.PalettePanel=sn;exports.PaperSizePanel=nn;exports.PaperSizePreset=pe;exports.PluginPanels=Us;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=_e;exports.SelectionBorder=Hn;exports.SelectionLayer=Xt;exports.Sidebar=dr;exports.TabPanel=St;exports.Tabs=Lt;exports.TabsContent=Ee;exports.TabsList=Ot;exports.TabsTrigger=ye;exports.TextInput=Pe;exports.ValidationSeverity=Dn;exports.VerticalAlign=Ce;exports.Z_INDEX=B;exports.alignmentDefinition=fn;exports.assertFinite=go;exports.assertInteger=ut;exports.assertNonNegative=ne;exports.assertPositive=ct;exports.assertRange=jn;exports.binarySearch=et;exports.calculateGridResize=jt;exports.calculateResizedLayout=Yt;exports.clampBlockToGrid=Zn;exports.clampMultipleBlocks=zt;exports.cleanupPrint=Un;exports.createBlock=Ne;exports.createBlockId=yn;exports.createInitialProps=wn;exports.createPluginRegistry=uo;exports.deserializeSchema=$t;exports.deserializeValues=Ct;exports.dimensionToString=Sn;exports.dimensionsToStrings=So;exports.distributeRemainder=Bn;exports.executePrint=Jo;exports.findBlockAtPoint=Mt;exports.findGridIndex=It;exports.fontStyleDefinition=co;exports.getBlockContainerStyle=Bt;exports.getBlockZIndex=$n;exports.getCommonValue=ge;exports.getMaxBlockCount=yo;exports.getMaxStep=Nt;exports.getPaperSize=qo;exports.getStrokeDasharray=ke;exports.getSubZIndex=Ye;exports.globalDragStore=ze;exports.gridToMms=ot;exports.gridToPxs=Zo;exports.imageDefinition=mo;exports.interactionZIndexs=J;exports.isValidHex=Fr;exports.mmsToPxs=st;exports.multilineDefinition=ho;exports.paddingDefinition=vn;exports.parseColor=yt;exports.placeholderDefinition=fo;exports.preparePrint=Vn;exports.printElement=Dt;exports.removeUndefinedProps=it;exports.serializeSchema=Tt;exports.serializeValues=Rt;exports.sizeDefinition=po;exports.stringToDimension=An;exports.stringsToDimensions=Ro;exports.toHex=pn;exports.toMm=Y;exports.toPx=V;exports.toRgbaString=Ur;exports.universalProperties=lo;exports.useGridCalc=Xe;exports.useInteractionState=Xn;exports.validateSchema=Fn;exports.validateValues=Wn;exports.validationDefinition=xo;
|
|
69
|
+
`,document.head.appendChild(v),()=>{const g=document.getElementById("printable-note-page-style");g&&g.remove()}},[t.paper]),u.useImperativeHandle(s,()=>({print:()=>{i.current&&$e(i.current,{title:"Document"})},openPrintPreview:()=>{i.current&&$e(i.current,{title:"Document"})}}),[]),r.jsx("div",{ref:i,className:o,style:{width:`${a.canvas.width}px`,height:`${a.canvas.height}px`,backgroundColor:"#fff",paddingTop:`${a.margin.top}px`,paddingLeft:`${a.margin.left}px`,paddingRight:`${a.margin.right}px`,paddingBottom:`${a.margin.bottom}px`,boxSizing:"border-box"},children:r.jsx("div",{style:{position:"relative",width:`${a.content.width}px`,height:`${a.content.height}px`},children:r.jsx(St,{blocks:t.blocks,pluginRegistry:n,mode:it.VIEW,values:e??{},getBlockRectPx:l,showGuides:!1,showBorder:!0})})})};sr.displayName="NotePrint";const ds=u.memo(u.forwardRef(sr));function vt(t,e){if(t.length===0)return;const n=(a,l)=>{let c=a;for(const m of l){if(c==null||typeof c!="object"||Array.isArray(c))return;c=c[m]}return c},o=e.split("."),s=n(t[0],o);return t.every(a=>n(a,o)===s)?s:void 0}const ms="_container_1tfjv_1",hs="_row_1tfjv_20",fs="_inputWrapper_1tfjv_37",ye={container:ms,row:hs,inputWrapper:fs},ir=({selectedBlocks:t,onUpdateBlocks:e})=>{if(t.length===0)return null;const n=o=>{const s={};t.forEach(i=>{s[i.id]={style:{...i.style,backgroundColor:o}}}),e(s)};return r.jsx("div",{className:ye.container,children:r.jsx("div",{className:ye.row,children:r.jsx("div",{className:ye.inputWrapper,children:r.jsx(Wt,{value:vt(t,"style.backgroundColor"),onChange:n,allowUndefined:!0,placeholder:"無色",height:24})})})})};function _t(t,e,n){const o=e.split("."),s=(i,a)=>{const l=o[a];if(a===o.length-1){if(n==null){const{[l]:d,...f}=i;return f}return{...i,[l]:n}}const c=(i==null?void 0:i[l])||{},m=s(c,a+1);if(Object.keys(m).length===0){const{[l]:d,...f}=i;return f}return{...i,[l]:m}};return s(t,0)}const ar=({selectedBlocks:t,onUpdateBlocks:e})=>{const n=(a,l,c)=>{const m={};t.forEach(d=>{var v,g,E;let f=_t(d.style||{},`border.${a}.${l}`,c);if(l==="type"&&c==null&&(f=_t(f,`border.${a}.width`,void 0),f=_t(f,`border.${a}.color`,void 0)),l==="type"&&c!==void 0&&c!==null){const y=(v=d.style)==null?void 0:v.border,p=y==null?void 0:y[a];p!=null&&p.width||(f=_t(f,`border.${a}.width`,{value:1,unit:"px"})),p!=null&&p.color||(f=_t(f,`border.${a}.color`,"#000000"))}if(l==="color"&&c!==void 0&&c!==null){const y=(g=d.style)==null?void 0:g.border,p=y==null?void 0:y[a];p!=null&&p.type||(f=_t(f,`border.${a}.type`,dt.SOLID)),p!=null&&p.width||(f=_t(f,`border.${a}.width`,{value:1,unit:"px"}))}if(l==="width"&&c!==void 0&&c!==null){const y=(E=d.style)==null?void 0:E.border,p=y==null?void 0:y[a];p!=null&&p.type||(f=_t(f,`border.${a}.type`,dt.SOLID)),p!=null&&p.color||(f=_t(f,`border.${a}.color`,"#000000"))}m[d.id]={style:f}}),e(m)},o=u.useMemo(()=>{var d;if(t.length!==1)return null;const a=t[0];if(!((d=a==null?void 0:a.style)!=null&&d.border))return null;const l=a.style.border;if(!l)return null;const c=f=>f?!(f.type&&!f.width):!0;return["all","top","right","bottom","left"].every(f=>c(l[f]))?new kt(l):null},[t]),s=a=>r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[r.jsx(wt,{value:vt(t,`style.border.${a}.type`),onChange:l=>n(a,"type",l),placeholder:"スタイル",height:24,options:[{label:"",value:void 0},{label:"実線",value:dt.SOLID},{label:"破線",value:dt.DASHED},{label:"点線",value:dt.DOTTED}]}),r.jsx(rt,{value:vt(t,`style.border.${a}.width`),onChange:l=>n(a,"width",l),placeholder:"太さ",height:24,allowedUnits:bn,min:1}),r.jsx(Wt,{value:vt(t,`style.border.${a}.color`),onChange:l=>n(a,"color",l),placeholder:"色",height:24,allowUndefined:!0})]}),i={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"})]}),o?r.jsx("div",{style:{position:"absolute",top:0,left:0,width:"80px",height:"80px",pointerEvents:"none"},children:r.jsx(It,{width:80,height:80,border:o})}):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(Oe,{defaultValue:"all",variant:"segmented",children:[r.jsx("div",{style:{width:"100%"},children:r.jsxs(Ge,{style:{width:"100%",display:"flex"},children:[r.jsx(yt,{value:"all",height:24,style:i,children:"共通"}),r.jsx(yt,{value:"top",height:24,style:i,children:"上"}),r.jsx(yt,{value:"bottom",height:24,style:i,children:"下"}),r.jsx(yt,{value:"left",height:24,style:i,children:"左"}),r.jsx(yt,{value:"right",height:24,style:i,children:"右"})]})}),r.jsxs("div",{style:{marginTop:"4px"},children:[r.jsx(Et,{value:"all",children:s("all")}),r.jsx(Et,{value:"top",children:s("top")}),r.jsx(Et,{value:"bottom",children:s("bottom")}),r.jsx(Et,{value:"left",children:s("left")}),r.jsx(Et,{value:"right",children:s("right")})]})]})})]})},ps="_container_1daw7_1",xs="_grid_1daw7_19",vs="_field_1daw7_26",bs="_label_1daw7_33",gs="_inputWrapper_1daw7_43",at={container:ps,grid:xs,field:vs,label:bs,inputWrapper:gs},lr=({selectedBlocks:t,onUpdateBlocks:e,gridSize:n})=>{if(t.length===0)return null;const o=t.length>1,s=o?Math.min(...t.map(l=>l.layout.x)):void 0,i=o?Math.min(...t.map(l=>l.layout.y)):void 0,a=(l,c)=>{if(c===void 0)return;const m={};if(o&&(l==="x"||l==="y")){const d=l==="x"?s:i;if(d===void 0)return;const f=Math.max(...t.map(x=>x.layout.x+x.layout.w)),v=Math.max(...t.map(x=>x.layout.y+x.layout.h)),g=f-(s??0),E=v-(i??0);let y=c;l==="x"&&n?y=Math.max(0,Math.min(c,n.cols-g)):l==="y"&&n?y=Math.max(0,Math.min(c,n.rows-E)):y=Math.max(0,c);const p=y-d;t.forEach(x=>{const h=x.layout[l]+p;m[x.id]={layout:{...x.layout,[l]:h}}})}else t.forEach(d=>{let f=c;if(l==="x"&&n)f=Math.max(0,Math.min(c,n.cols-d.layout.w));else if(l==="y"&&n)f=Math.max(0,Math.min(c,n.rows-d.layout.h));else if(l==="w"&&n){const v=n.cols-d.layout.x;f=Math.max(1,Math.min(c,v))}else if(l==="h"&&n){const v=n.rows-d.layout.y;f=Math.max(1,Math.min(c,v))}else l==="w"||l==="h"?f=Math.max(1,c):f=Math.max(0,c);m[d.id]={layout:{...d.layout,[l]:f}}});e(m)};return r.jsx("div",{className:at.container,children:r.jsxs("div",{className:at.grid,children:[r.jsxs("div",{className:at.field,children:[r.jsx("span",{className:at.label,children:"X"}),r.jsx("div",{className:at.inputWrapper,children:r.jsx(st,{value:o?s:vt(t,"layout.x"),onChange:l=>a("x",l),min:0,max:n?n.cols-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),r.jsxs("div",{className:at.field,children:[r.jsx("span",{className:at.label,children:"Y"}),r.jsx("div",{className:at.inputWrapper,children:r.jsx(st,{value:o?i:vt(t,"layout.y"),onChange:l=>a("y",l),min:0,max:n?n.rows-1:void 0,integer:!0,height:22,placeholder:"-"})})]}),!o&&r.jsxs("div",{className:at.field,children:[r.jsx("span",{className:at.label,children:"W"}),r.jsx("div",{className:at.inputWrapper,children:r.jsx(st,{value:vt(t,"layout.w"),onChange:l=>a("w",l),min:1,max:n==null?void 0:n.cols,integer:!0,height:22,placeholder:"-"})})]}),!o&&r.jsxs("div",{className:at.field,children:[r.jsx("span",{className:at.label,children:"H"}),r.jsx("div",{className:at.inputWrapper,children:r.jsx(st,{value:vt(t,"layout.h"),onChange:l=>a("h",l),min:1,max:n==null?void 0:n.rows,integer:!0,height:22,placeholder:"-"})})]})]})})},ws="_container_1h4w8_1",_s="_row_1h4w8_10",ys="_label_1h4w8_16",Es="_inputWrapper_1h4w8_25",Dt={container:ws,row:_s,label:ys,inputWrapper:Es},cr=({selectedBlocks:t,onUpdateBlocks:e})=>{const[n,o]=u.useState(""),s=t[0];u.useEffect(()=>{t.length===1&&s&&o(s.id)},[t,s]);const i=()=>{if(!s)return;const c=s.id,m=n.trim();if(m===c||!m){o(c);return}e({[c]:{id:m}})},a=c=>{o(c??"")},l=c=>{const m={};t.forEach(d=>{m[d.id]={behavior:{...d.behavior,readOnly:!!c}}}),e(m)};return r.jsxs("div",{className:Dt.container,children:[t.length===1&&r.jsxs("div",{className:Dt.row,children:[r.jsx("span",{className:Dt.label,children:"ID"}),r.jsx("div",{className:Dt.inputWrapper,children:r.jsx(At,{value:n,onChange:a,onBlur:i,placeholder:"IDを入力",height:16})})]}),t.length>0&&r.jsx("div",{className:Dt.row,children:r.jsx("div",{className:Dt.inputWrapper,children:r.jsx(xt,{label:"読み取り専用",value:!!vt(t,"behavior.readOnly"),onChange:l})})})]})},js="_container_wa11y_1",Ns="_scrollArea_wa11y_18",Is="_section_wa11y_26",Ds="_sectionTitle_wa11y_35",$s="_subsection_wa11y_47",Ts="_subsectionTitle_wa11y_51",Rs="_fields_wa11y_59",Ms="_emptyState_wa11y_69",ot={container:js,scrollArea:Ns,section:Is,sectionTitle:Ds,subsection:$s,subsectionTitle:Ts,fields:Rs,emptyState:Ms},Cs="_field_qo0ef_1",Ps="_label_qo0ef_7",As="_mixed_qo0ef_15",ks="_description_qo0ef_22",Qt={field:Cs,label:Ps,mixed:As,description:ks},pe=u.memo(({propertyKey:t,definition:e,selectedBlocks:n,onChange:o})=>{var d;const s=e.Component;if(!s)return null;const i=vt(n,`props.${t}`),c=!n.map(f=>f.props[t]).every(f=>f===void 0)&&i===void 0&&n.length>1,m={value:c?void 0:i!==void 0?i:e.defaultValue,onChange:f=>o(t,f),readOnly:!1,config:{...e.config,placeholder:c?"複数選択中 (値が異なります)":(d=e.config)==null?void 0:d.placeholder}};return r.jsxs("div",{className:Qt.field,children:[e.label&&r.jsx("div",{className:Qt.label,title:e.description,children:e.label}),r.jsx(s,{...m}),c&&r.jsx("span",{className:Qt.mixed,children:"(混在)"}),e.description&&r.jsx("p",{className:Qt.description,children:e.description})]})});pe.displayName="PropertyField";function Ss(t){return t!==!1}const Je=u.memo(({selectedBlocks:t,pluginRegistry:e,onUpdateBlocks:n,gridSize:o,className:s=""})=>{const i=t[0],a=i?e[i.kind]:void 0,l=u.useMemo(()=>{var f;if(t.length===0)return!1;const d=(f=t[0])==null?void 0:f.kind;return t.every(v=>v.kind===d)},[t]),c=u.useMemo(()=>{if(!i||!a)return{};const d={};let f;if(l)f=Object.entries(a.properties);else{const v=t.map(p=>e[p.kind]).filter(p=>p!==void 0);if(v.length===0)return{};const g=v[0];if(!g)return{};const E=new Set(Object.keys(g.properties));f=Array.from(E).filter(p=>v.every(x=>p in x.properties)).map(p=>{const x=a.properties[p];return x?[p,x]:null}).filter(p=>p!==null)}return f.forEach(([v,g])=>{if(!Ss(g)||t.length>1&&g.disableInMultiSelection||g.condition&&!g.condition(i.props))return;const E=g.group||"基本";d[E]||(d[E]=[]),g.Component&&d[E].push({key:v,definition:g})}),d},[a,e,t,i,l]),m=(d,f)=>{const v={};t.forEach(g=>{v[g.id]={props:{...g.props,[d]:f}}}),n(v)};return t.length===0?r.jsx("div",{className:`${ot.container} ${s}`,children:r.jsxs("div",{className:ot.emptyState,children:["ブロックを選択すると",r.jsx("br",{}),"プロパティが表示されます"]})}):r.jsx("div",{className:`${ot.container} ${s}`,children:r.jsxs("div",{className:ot.scrollArea,children:[r.jsxs("div",{className:ot.section,children:[r.jsx("div",{className:ot.sectionTitle,children:"配置・サイズ"}),r.jsx(lr,{selectedBlocks:t,onUpdateBlocks:n,gridSize:o})]}),r.jsxs("div",{className:ot.section,children:[r.jsx("div",{className:ot.sectionTitle,children:"背景"}),r.jsx(ir,{selectedBlocks:t,onUpdateBlocks:n})]}),r.jsxs("div",{className:ot.section,children:[r.jsx("div",{className:ot.sectionTitle,children:"枠線"}),r.jsx(ar,{selectedBlocks:t,onUpdateBlocks:n})]}),a&&Object.keys(c).length>0&&r.jsx("div",{className:ot.section,children:Object.entries(c).map(([d,f])=>r.jsxs("div",{className:ot.subsection,children:[r.jsx("div",{className:ot.subsectionTitle,children:d}),r.jsx("div",{className:ot.fields,children:f.map(({key:v,definition:g})=>r.jsx(pe,{propertyKey:v,definition:g,selectedBlocks:t,onChange:m},v))})]},d))}),r.jsxs("div",{className:ot.section,children:[r.jsx("div",{className:ot.sectionTitle,children:"基本設定"}),r.jsx(cr,{selectedBlocks:t,onUpdateBlocks:n})]})]})})});Je.displayName="BlockPropertyPanel";const Ls="_panel_1h33v_1",Os="_header_1h33v_11",Gs="_group_1h33v_18",Bs="_groupTitle_1h33v_26",Vs="_groupContent_1h33v_36",Vt={panel:Ls,header:Os,group:Gs,groupTitle:Bs,groupContent:Vs};function Us(t){return t!==!1}const Fs=({selectedBlocks:t,pluginRegistry:e,onUpdateBlocks:n})=>{const o=t[0],s=o?e[o.kind]:void 0,i=u.useMemo(()=>{if(!o||!s)return{};const l={};return Object.entries(s.properties).forEach(([c,m])=>{if(!Us(m)||t.length>1&&m.disableInMultiSelection||m.condition&&!m.condition(o.props))return;const d=m.group||"基本";l[d]||(l[d]=[]),m.Component&&l[d].push({key:c,definition:m})}),l},[s,t.length,o]),a=(l,c)=>{const m={};t.forEach(d=>{m[d.id]={props:{...d.props,[l]:c}}}),n(m)};return!o||!s||t.length===0?null:r.jsxs("div",{className:Vt.panel,children:[r.jsx("div",{className:Vt.header,children:t.length>1?`${t.length}個のブロック`:s.meta.displayName}),Object.entries(i).map(([l,c])=>r.jsxs("div",{className:Vt.group,children:[r.jsx("div",{className:Vt.groupTitle,children:l}),r.jsx("div",{className:Vt.groupContent,children:c.map(({key:m,definition:d})=>r.jsx(pe,{propertyKey:m,definition:d,selectedBlocks:t,onChange:a},m))})]},l))]})},zs="_panel_1ekwd_6",Ws="_title_1ekwd_10",Ys="_content_1ekwd_22",Hs="_description_1ekwd_29",Xs="_list_1ekwd_35",qs="_item_1ekwd_44",Ks="_dragging_1ekwd_61",Zs="_dragOver_1ekwd_66",Js="_dragHandle_1ekwd_71",Qs="_itemInfo_1ekwd_86",ti="_itemId_1ekwd_93",ei="_itemMeta_1ekwd_98",ni="_itemKind_1ekwd_105",ri="_itemActions_1ekwd_113",oi="_actionButton_1ekwd_118",si="_empty_1ekwd_154",J={panel:zs,title:Ws,content:Ys,description:Hs,list:Xs,item:qs,dragging:Ks,dragOver:Zs,dragHandle:Js,itemInfo:Qs,itemId:ti,itemMeta:ei,itemKind:ni,itemActions:ri,actionButton:oi,empty:si},Qe=({blocks:t,onBlocksChange:e})=>{const[n,o]=u.useState(null),[s,i]=u.useState(null),a=[...t].reverse(),l=u.useCallback(p=>{const x=t.findIndex(N=>N.id===p);if(x===-1||x===t.length-1)return;const h=[...t],[w]=h.splice(x,1);w&&(h.push(w),e(h))},[t,e]),c=u.useCallback(p=>{const x=t.findIndex(N=>N.id===p);if(x===-1||x===0)return;const h=[...t],[w]=h.splice(x,1);w&&(h.unshift(w),e(h))},[t,e]),m=u.useCallback(p=>{const x=t.findIndex(I=>I.id===p);if(x===-1||x===t.length-1)return;const h=[...t],w=h[x],N=h[x+1];!w||!N||(h[x]=N,h[x+1]=w,e(h))},[t,e]),d=u.useCallback(p=>{const x=t.findIndex(I=>I.id===p);if(x===-1||x===0)return;const h=[...t],w=h[x],N=h[x-1];!w||!N||(h[x]=N,h[x-1]=w,e(h))},[t,e]),f=u.useCallback((p,x)=>{var w;o(x),p.dataTransfer.effectAllowed="move";const h=t.length-1-x;p.currentTarget&&p.dataTransfer.setData("text/plain",((w=t[h])==null?void 0:w.id)||"")},[t]),v=u.useCallback(()=>{o(null),i(null)},[]),g=u.useCallback((p,x)=>{p.preventDefault(),p.dataTransfer.dropEffect="move",!(n===null||n===x)&&i(x)},[n]),E=u.useCallback(()=>{i(null)},[]),y=u.useCallback((p,x)=>{if(p.preventDefault(),n===null||n===x){o(null),i(null);return}const h=t.length-1-n,w=t.length-1-x,N=[...t],[I]=N.splice(h,1);I&&(N.splice(w,0,I),e(N),o(null),i(null))},[t,n,e]);return r.jsxs("div",{className:J.panel,children:[r.jsx("h3",{className:J.title,children:"ブロック順序"}),r.jsxs("div",{className:J.content,children:[r.jsx("p",{className:J.description,children:"上が最前面、下が最背面"}),r.jsx("ul",{className:J.list,children:a.map((p,x)=>{const h=t.length-1-x;return r.jsxs("li",{className:`${J.item} ${n===x?J.dragging:""} ${s===x?J.dragOver:""}`,onDragOver:w=>g(w,x),onDragLeave:E,onDrop:w=>y(w,x),children:[r.jsx("button",{type:"button",className:J.dragHandle,title:"ドラッグして並び替え",draggable:!0,onDragStart:w=>f(w,x),onDragEnd:v,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:J.itemInfo,children:[r.jsx("div",{className:J.itemId,children:p.id}),r.jsx("div",{className:J.itemMeta,children:r.jsx("span",{className:J.itemKind,children:p.kind})})]}),r.jsxs("div",{className:J.itemActions,children:[r.jsx("button",{type:"button",className:J.actionButton,onClick:()=>l(p.id),title:"最前面へ","aria-label":"最前面へ移動",disabled:h===t.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:J.actionButton,onClick:()=>m(p.id),title:"前面へ","aria-label":"前面へ移動",disabled:h===t.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:J.actionButton,onClick:()=>d(p.id),title:"背面へ","aria-label":"背面へ移動",disabled:h===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:J.actionButton,onClick:()=>c(p.id),title:"最背面へ","aria-label":"最背面へ移動",disabled:h===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"})]})})]})]},p.id)})}),t.length===0&&r.jsx("div",{className:J.empty,children:"ブロックがありません"})]})]})};Qe.displayName="BlockOrderPanel";const tn=({schema:t,onSchemaChange:e})=>{const n=u.useCallback(i=>{e({...t,paper:i})},[t,e]),o=u.useCallback(i=>{e({...t,grid:i})},[t,e]),s=u.useCallback(i=>{e({...t,blocks:i})},[t,e]);return r.jsxs(Le,{children:[r.jsx(rn,{paper:t.paper,onPaperChange:n}),r.jsx(nn,{paper:t.paper,onPaperChange:n}),r.jsx(en,{grid:t.grid,onGridChange:o}),r.jsx(Qe,{blocks:t.blocks,onBlocksChange:s})]})};tn.displayName="CanvasPanel";const ii="_panel_1axyd_6",ai="_title_1axyd_10",li="_content_1axyd_22",ci="_field_1axyd_29",ui="_horizontal_1axyd_35",di="_label_1axyd_41",mi="_gridSizeRow_1axyd_52",gt={panel:ii,title:ai,content:li,field:ci,horizontal:ui,label:di,gridSizeRow:mi},en=({grid:t,onGridChange:e})=>{const n=u.useCallback(s=>{if(!s||s<1||s>100)return;const i=t.cols.length,a=[];if(s>i){a.push(...t.cols);for(let l=i;l<s;l++)a.push({value:1,unit:"fr"})}else a.push(...t.cols.slice(0,s));e({...t,cols:a})},[t,e]),o=u.useCallback(s=>{if(!s||s<1||s>100)return;const i=t.rows.length,a=[];if(s>i){a.push(...t.rows);for(let l=i;l<s;l++)a.push({value:1,unit:"fr"})}else a.push(...t.rows.slice(0,s));e({...t,rows:a})},[t,e]);return r.jsxs("div",{className:gt.panel,children:[r.jsx("h3",{className:gt.title,children:"グリッドサイズ"}),r.jsx("div",{className:gt.content,children:r.jsxs("div",{className:gt.gridSizeRow,children:[r.jsxs("div",{className:`${gt.field} ${gt.horizontal}`,children:[r.jsx("span",{className:gt.label,children:"列数"}),r.jsx(st,{value:t.cols.length,onChange:n,min:1,max:100,step:1})]}),r.jsxs("div",{className:`${gt.field} ${gt.horizontal}`,children:[r.jsx("span",{className:gt.label,children:"行数"}),r.jsx(st,{value:t.rows.length,onChange:o,min:1,max:100,step:1})]})]})})]})};en.displayName="GridSizePanel";const hi="_panel_qlcb6_6",fi="_header_qlcb6_10",pi="_title_qlcb6_20",xi="_headerActions_qlcb6_29",vi="_content_qlcb6_33",bi="_field_qlcb6_37",gi="_horizontal_qlcb6_43",wi="_label_qlcb6_49",_i="_marginsGrid_qlcb6_60",yi="_topMargin_qlcb6_66",Ei="_bottomMargin_qlcb6_67",ji="_sideMargins_qlcb6_73",K={panel:hi,header:fi,title:pi,headerActions:xi,content:vi,field:bi,horizontal:gi,label:wi,marginsGrid:_i,topMargin:yi,bottomMargin:Ei,sideMargins:ji},nn=({paper:t,onPaperChange:e})=>{const[n,o]=u.useState(!1),s=u.useCallback(m=>{m!==void 0&&o(m)},[]),i=u.useCallback(m=>{if(!m)return;const d=n?{top:m,right:m,bottom:m,left:m}:{...t.margin,top:m};e({...t,margin:d})},[t,e,n]),a=u.useCallback(m=>{m&&e({...t,margin:{...t.margin,right:m}})},[t,e]),l=u.useCallback(m=>{m&&e({...t,margin:{...t.margin,bottom:m}})},[t,e]),c=u.useCallback(m=>{m&&e({...t,margin:{...t.margin,left:m}})},[t,e]);return r.jsxs("div",{className:K.panel,children:[r.jsxs("div",{className:K.header,children:[r.jsx("h3",{className:K.title,children:"マージン"}),r.jsx("div",{className:K.headerActions,children:r.jsx(xt,{value:n,onChange:s,label:"全辺を一括設定"})})]}),r.jsx("div",{className:K.content,children:n?r.jsxs("div",{className:`${K.field} ${K.horizontal}`,children:[r.jsx("span",{className:K.label,children:"全辺"}),r.jsx(rt,{value:t.margin.top,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})]}):r.jsxs("div",{className:K.marginsGrid,children:[r.jsx("div",{className:`${K.field} ${K.horizontal} ${K.topMargin}`,children:r.jsx(rt,{value:t.margin.top,onChange:i,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsxs("div",{className:K.sideMargins,children:[r.jsx("div",{className:`${K.field} ${K.horizontal}`,children:r.jsx(rt,{value:t.margin.left,onChange:c,allowedUnits:["mm","cm","inch"],min:0,max:1e3})}),r.jsx("div",{className:`${K.field} ${K.horizontal}`,children:r.jsx(rt,{value:t.margin.right,onChange:a,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]}),r.jsx("div",{className:`${K.field} ${K.horizontal} ${K.bottomMargin}`,children:r.jsx(rt,{value:t.margin.bottom,onChange:l,allowedUnits:["mm","cm","inch"],min:0,max:1e3})})]})})]})};nn.displayName="MarginPanel";const Ni="_panel_16d9o_6",Ii="_title_16d9o_10",Di="_content_16d9o_22",$i="_field_16d9o_29",Ti="_horizontal_16d9o_35",Ri="_label_16d9o_41",Mi="_dimensionsRow_16d9o_52",ft={panel:Ni,title:Ii,content:Di,field:$i,horizontal:Ti,label:Ri,dimensionsRow:Mi},rn=({paper:t,onPaperChange:e})=>{const n=u.useMemo(()=>[{value:pt.A4,label:"A4 (210 × 297 mm)"},{value:pt.A3,label:"A3 (297 × 420 mm)"},{value:pt.B5,label:"B5 (182 × 257 mm)"},{value:pt.LETTER,label:"Letter (8.5 × 11 inch)"},{value:pt.LEGAL,label:"Legal (8.5 × 14 inch)"},{value:pt.CUSTOM,label:"カスタム"}],[]),o=u.useCallback(l=>{if(!l)return;const c=Be[l];e({...t,size:c})},[t,e]),s=u.useCallback(l=>{if(!l)return;const c={...t.size,preset:pt.CUSTOM,width:l};e({...t,size:c})},[t,e]),i=u.useCallback(l=>{if(!l)return;const c={...t.size,preset:pt.CUSTOM,height:l};e({...t,size:c})},[t,e]),a=t.size.preset===pt.CUSTOM;return r.jsxs("div",{className:ft.panel,children:[r.jsx("h3",{className:ft.title,children:"用紙サイズ"}),r.jsxs("div",{className:ft.content,children:[r.jsx("div",{className:ft.field,children:r.jsx(wt,{value:t.size.preset,options:n,onChange:o})}),a&&r.jsxs("div",{className:ft.dimensionsRow,children:[r.jsxs("div",{className:`${ft.field} ${ft.horizontal}`,children:[r.jsx("span",{className:ft.label,children:"幅"}),r.jsx(rt,{value:t.size.width,onChange:s,allowedUnits:["mm","cm","inch"],min:t.margin.left.value+t.margin.right.value+1,max:500})]}),r.jsxs("div",{className:`${ft.field} ${ft.horizontal}`,children:[r.jsx("span",{className:ft.label,children:"高さ"}),r.jsx(rt,{value:t.size.height,onChange:i,allowedUnits:["mm","cm","inch"],min:t.margin.top.value+t.margin.bottom.value+1,max:500})]})]})]})]})};rn.displayName="PaperSizePanel";const Ci="_section_p4xnx_6",Pi="_title_p4xnx_14",Ai="_content_p4xnx_26",ki="_buttonGroup_p4xnx_33",Si="_button_p4xnx_33",Li="_error_p4xnx_65",Q={section:Ci,title:Pi,content:Ai,buttonGroup:ki,button:Si,error:Li},on=({schema:t,values:e,onSchemaChange:n,onValuesChange:o})=>{const[s,i]=u.useState(""),a=u.useRef(null),l=u.useRef(null),c=u.useCallback(()=>{try{const h=Re(t,!0),w=new Blob([h],{type:"application/json"}),N=URL.createObjectURL(w),I=document.createElement("a");I.href=N,I.download="schema.json",I.click(),URL.revokeObjectURL(N),i("")}catch(h){i(`エクスポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[t]),m=u.useCallback(async()=>{try{const h=Re(t,!0);await navigator.clipboard.writeText(h),i(""),alert("スキーマをクリップボードにコピーしました")}catch(h){i(`クリップボードエラー: ${h instanceof Error?h.message:String(h)}`)}},[t]),d=u.useCallback(()=>{var h;(h=a.current)==null||h.click()},[]),f=u.useCallback(h=>{var I;const w=(I=h.target.files)==null?void 0:I[0];if(!w)return;const N=new FileReader;N.onload=B=>{var $;try{const A=($=B.target)==null?void 0:$.result,L=Te(A);n(L),i(""),alert("スキーマをインポートしました")}catch(A){i(`インポートエラー: ${A instanceof Error?A.message:String(A)}`)}},N.readAsText(w),h.target.value=""},[n]),v=u.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),w=Te(h);n(w),i(""),alert("スキーマをインポートしました")}catch(h){i(`インポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[n]),g=u.useCallback(()=>{try{const h=Ce(e,!0),w=new Blob([h],{type:"application/json"}),N=URL.createObjectURL(w),I=document.createElement("a");I.href=N,I.download="values.json",I.click(),URL.revokeObjectURL(N),i("")}catch(h){i(`エクスポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[e]),E=u.useCallback(async()=>{try{const h=Ce(e,!0);await navigator.clipboard.writeText(h),i(""),alert("値をクリップボードにコピーしました")}catch(h){i(`クリップボードエラー: ${h instanceof Error?h.message:String(h)}`)}},[e]),y=u.useCallback(()=>{var h;(h=l.current)==null||h.click()},[]),p=u.useCallback(h=>{var I;const w=(I=h.target.files)==null?void 0:I[0];if(!w)return;const N=new FileReader;N.onload=B=>{var $;try{const A=($=B.target)==null?void 0:$.result,L=Me(A);o(L),i(""),alert("値をインポートしました")}catch(A){i(`インポートエラー: ${A instanceof Error?A.message:String(A)}`)}},N.readAsText(w),h.target.value=""},[o]),x=u.useCallback(async()=>{try{const h=await navigator.clipboard.readText(),w=Me(h);o(w),i(""),alert("値をインポートしました")}catch(h){i(`インポートエラー: ${h instanceof Error?h.message:String(h)}`)}},[o]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:Q.section,children:[r.jsx("h3",{className:Q.title,children:"スキーマ"}),r.jsxs("div",{className:Q.content,children:[r.jsxs("div",{className:Q.buttonGroup,children:[r.jsx("button",{type:"button",className:Q.button,onClick:c,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:Q.button,onClick:m,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:Q.buttonGroup,children:[r.jsx("button",{type:"button",className:Q.button,onClick:d,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:Q.button,onClick:v,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:a,type:"file",accept:".json",style:{display:"none"},onChange:f})]})]}),r.jsxs("div",{className:Q.section,children:[r.jsx("h3",{className:Q.title,children:"値"}),r.jsxs("div",{className:Q.content,children:[r.jsxs("div",{className:Q.buttonGroup,children:[r.jsx("button",{type:"button",className:Q.button,onClick:g,children:"📥 ファイルにエクスポート"}),r.jsx("button",{type:"button",className:Q.button,onClick:E,children:"📋 クリップボードにコピー"})]}),r.jsxs("div",{className:Q.buttonGroup,children:[r.jsx("button",{type:"button",className:Q.button,onClick:y,children:"📤 ファイルからインポート"}),r.jsx("button",{type:"button",className:Q.button,onClick:x,children:"📋 クリップボードからペースト"})]}),r.jsx("input",{ref:l,type:"file",accept:".json",style:{display:"none"},onChange:p})]})]}),s&&r.jsx("div",{className:Q.error,role:"alert",children:s})]})};on.displayName="ImportExportPanel";const sn=({schema:t,values:e,onSchemaChange:n,onValuesChange:o})=>r.jsx(Le,{children:r.jsx(on,{schema:t,values:e,onSchemaChange:n,onValuesChange:o})});sn.displayName="OtherPanel";const Oi="_container_6c3ft_3",Gi="_paletteItems_6c3ft_32",Bi="_item_6c3ft_44",Vi="_itemName_6c3ft_70",Ui="_itemPreview_6c3ft_98",Ft={container:Oi,paletteItems:Gi,item:Bi,itemName:Vi,itemPreview:Ui},an=({plugins:t,className:e})=>{const[n,o]=u.useState(null),s=u.useCallback((i,a)=>{o({plugin:i,mousePos:a,isOverCanvas:!1});const l=m=>{const d=document.elementFromPoint(m.clientX,m.clientY),f=!!(d!=null&&d.closest('[data-testid="interaction-layer"]'));o(v=>v?{...v,mousePos:{x:m.clientX,y:m.clientY},isOverCanvas:f}:null)},c=()=>{o(null),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",c)};window.addEventListener("pointermove",l),window.addEventListener("pointerup",c)},[]);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:`${Ft.container} ${e||""}`,children:r.jsx("div",{className:Ft.paletteItems,children:t.map(i=>r.jsx(ur,{plugin:i,onDragStart:s},i.kind))})}),n&&!n.isOverCanvas&&r.jsx(dr,{plugin:n.plugin,mousePos:n.mousePos})]})};an.displayName="PalettePanel";const ur=({plugin:t,onDragStart:e})=>{const n=u.useMemo(()=>Nt(t,{x:0,y:0,w:t.meta.defaultSize.w,h:t.meta.defaultSize.h},{}),[t]),o=u.useMemo(()=>{if(t.validateValue)return t.validateValue(void 0,n.props)},[t,n.props]),s=u.useCallback(i=>{i.preventDefault(),zt.start(t.kind,t.meta.defaultSize),e(t,{x:i.clientX,y:i.clientY});const a=()=>{zt.end(),window.removeEventListener("pointerup",a)};window.addEventListener("pointerup",a)},[t,e]);return r.jsxs("div",{className:Ft.item,children:[r.jsx("button",{type:"button",onPointerDown:s,className:Ft.itemName,"aria-label":`${t.meta.displayName}ブロックを追加`,children:t.meta.displayName}),r.jsx("div",{className:Ft.itemPreview,onPointerDown:s,"aria-hidden":"true",children:r.jsx(t.Renderer,{id:n.id,props:n.props,value:o,onChange:()=>{},readOnly:!0,mode:it.FORM})})]})};ur.displayName="PaletteItem";const dr=({plugin:t,mousePos:e})=>{const n=u.useMemo(()=>Nt(t,{x:0,y:0,w:t.meta.defaultSize.w,h:t.meta.defaultSize.h},{}),[t]),o=u.useMemo(()=>{if(t.validateValue)return t.validateValue(void 0,n.props)},[t,n.props]),s={width:t.meta.defaultSize.w*50,height:t.meta.defaultSize.h*50};return r.jsx("div",{"data-testid":"palette-drag-ghost",style:{position:"fixed",left:`${e.x-s.width/2}px`,top:`${e.y-s.height/2}px`,width:`${s.width}px`,height:`${s.height}px`,pointerEvents:"none",opacity:.5,filter:"grayscale(50%)",zIndex:9999,border:"2px dashed #3b82f6",backgroundColor:"#fff"},children:r.jsx(t.Renderer,{id:n.id,props:n.props,value:o,onChange:()=>{},readOnly:!0,mode:it.FORM})})};dr.displayName="DragGhost";const Fi="_container_rt0ql_3",zi="_tabHeader_rt0ql_14",Wi="_tabContent_rt0ql_21",Ut={container:Fi,tabHeader:zi,tabContent:Wi},mr=({blocks:t,selectedBlockIds:e,pluginRegistry:n,onUpdateBlocks:o,schema:s,values:i,onSchemaChange:a,onValuesChange:l,gridSize:c,className:m})=>{const d=u.useMemo(()=>Object.values(n),[n]),f=u.useMemo(()=>t.filter(g=>e.includes(g.id)),[t,e]),v=e.length>0;return r.jsx("div",{className:`${Ut.container} ${m||""}`,"data-sidebar":"true",children:r.jsxs(Oe,{defaultValue:"block",variant:"default",children:[r.jsxs(Ge,{className:Ut.tabHeader,children:[r.jsx(yt,{value:"block",children:"ブロック"}),r.jsx(yt,{value:"canvas",children:"キャンバス"}),r.jsx(yt,{value:"other",children:"その他"})]}),r.jsx(Et,{value:"block",className:Ut.tabContent,children:v?r.jsx(Je,{selectedBlocks:f,pluginRegistry:n,onUpdateBlocks:o,gridSize:c}):r.jsx(an,{plugins:d})}),r.jsx(Et,{value:"canvas",className:Ut.tabContent,children:r.jsx(tn,{schema:s,onSchemaChange:a})}),r.jsx(Et,{value:"other",className:Ut.tabContent,children:r.jsx(sn,{schema:s,values:i,onSchemaChange:a,onValuesChange:l})})]})})};mr.displayName="Sidebar";exports.ACTUAL_UNITS=io;exports.ALL_UNITS=so;exports.BLOCK_SUB_INDEX=mt;exports.BORDER_UNITS=bn;exports.BackgroundPanel=ir;exports.BlockBorder=Rn;exports.BlockCanvas=Mn;exports.BlockChangeType=ct;exports.BlockContainer=Ue;exports.BlockGuideBorder=Pn;exports.BlockLayer=St;exports.BlockOrderPanel=Qe;exports.BlockPropertyPanel=Je;exports.BlockRenderer=Ht;exports.Border=kt;exports.BorderOverlay=An;exports.BorderPanel=ar;exports.BorderRenderer=It;exports.COLOR_PALETTE=vn;exports.CanvasPanel=tn;exports.Checkbox=xt;exports.ColorPalette=Ae;exports.ColorPicker=Wt;exports.ColorPickerPopover=Se;exports.DEFAULT_DPI=W;exports.DEFAULT_FONT_FAMILY=_n;exports.DEFAULT_GRID=jn;exports.DEFAULT_GUIDE_BORDER=me;exports.DEFAULT_GUIDE_LINE=Cn;exports.DEFAULT_PAPER=Dn;exports.DEFAULT_PAPER_MARGIN=In;exports.DEFAULT_PAPER_SIZES=Be;exports.DEFAULT_SCHEMA=yo;exports.DimensionInput=rt;exports.DragLayer=qe;exports.DragType=nt;exports.EditingBlock=qn;exports.FONT_UNITS=gn;exports.GRID_UNITS=lo;exports.GridCanvas=kn;exports.GridDimensionLabel=ee;exports.GridLayer=he;exports.GridOverlay=Gn;exports.GridResizeHandle=ne;exports.GridSizePanel=en;exports.HorizontalAlign=Tt;exports.ImageObjectFit=jt;exports.ImportExportPanel=on;exports.InsertGhost=ze;exports.InteractionBlock=Lt;exports.InteractionEventType=H;exports.InteractionLayer=Ze;exports.InteractionMode=lt;exports.LayoutPanel=lr;exports.LineType=dt;exports.MarginOverlay=Bn;exports.MarginPanel=nn;exports.MetaPanel=cr;exports.MovingGhost=Ye;exports.MultilineWhiteSpace=Ct;exports.MultilineWordWrap=Mt;exports.NoteEdit=Qn;exports.NoteEditor=us;exports.NoteForm=er;exports.NoteMode=it;exports.NotePrint=ds;exports.NoteView=rr;exports.NumberInput=st;exports.OtherPanel=sn;exports.PADDING_UNITS=$t;exports.PAPER_UNITS=ao;exports.PalettePanel=an;exports.PaperSizePanel=rn;exports.PaperSizePreset=pt;exports.PluginPanels=Fs;exports.PropertyField=pe;exports.RESIZE_HANDLE_STYLE=fe;exports.RGBAInputs=ke;exports.ResizeGhost=Xe;exports.ResizeHandle=X;exports.ResizeHandles=Fe;exports.SELECTION_STYLE=Xt;exports.SIZE_UNITS=je;exports.Select=wt;exports.SelectionBorder=Xn;exports.SelectionLayer=Ke;exports.Sidebar=mr;exports.TabPanel=Le;exports.Tabs=Oe;exports.TabsContent=Et;exports.TabsList=Ge;exports.TabsTrigger=yt;exports.TextInput=At;exports.ValidationSeverity=$n;exports.VerticalAlign=Rt;exports.Z_INDEX=G;exports.alignmentDefinition=pn;exports.assertFinite=bo;exports.assertInteger=de;exports.assertNonNegative=et;exports.assertPositive=ue;exports.assertRange=Nn;exports.binarySearch=te;exports.calculateGridResize=Ne;exports.calculateResizedLayout=He;exports.clampBlockToGrid=Zn;exports.clampMultipleBlocks=We;exports.cleanupPrint=Fn;exports.createBlock=Nt;exports.createBlockId=En;exports.createInitialProps=yn;exports.createPluginRegistry=mo;exports.deserializeSchema=Te;exports.deserializeValues=Me;exports.dimensionToString=Ln;exports.dimensionsToStrings=Lo;exports.distributeRemainder=Vn;exports.executePrint=Qo;exports.findBlockAtPoint=Pe;exports.findGridIndex=De;exports.fontStyleDefinition=uo;exports.getBlockContainerStyle=Ve;exports.getBlockZIndex=Tn;exports.getCommonValue=vt;exports.getInteractionMode=ae;exports.getMaxBlockCount=Eo;exports.getMaxStep=Ie;exports.getPaperSize=Jo;exports.getStrokeDasharray=Pt;exports.getSubZIndex=Yt;exports.globalDragStore=zt;exports.gridToMms=oe;exports.gridToPxs=Zo;exports.imageDefinition=ho;exports.interactionZIndexs=Z;exports.isValidHex=zr;exports.mmsToPxs=se;exports.multilineDefinition=fo;exports.paddingDefinition=wn;exports.parseColor=Ee;exports.placeholderDefinition=po;exports.preparePrint=Un;exports.printElement=$e;exports.removeUndefinedProps=ie;exports.serializeSchema=Re;exports.serializeValues=Ce;exports.sizeDefinition=xo;exports.stringToDimension=Sn;exports.stringsToDimensions=Co;exports.toHex=xn;exports.toMm=Y;exports.toPx=V;exports.toRgbaString=Fr;exports.universalProperties=co;exports.useGridCalc=qt;exports.useInteractionState=Kn;exports.validateSchema=zn;exports.validateValues=Yn;exports.validationDefinition=vo;
|
|
70
70
|
//# sourceMappingURL=index.js.map
|