@tatamicks/core 1.0.2 → 1.0.3
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/{PalettePanel-BMZ6dfI3.cjs → PalettePanel-0cFP3tbA.cjs} +2 -2
- package/dist/PalettePanel-0cFP3tbA.cjs.map +1 -0
- package/dist/{PalettePanel-Cigl9i1N.js → PalettePanel-N5Y1TJAk.js} +151 -166
- package/dist/PalettePanel-N5Y1TJAk.js.map +1 -0
- package/dist/canvas.cjs +1 -1
- package/dist/canvas.mjs +4 -4
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{paperSettingsWidget-7766a5Fe.cjs → paperSettingsWidget-CJ4QFjYK.cjs} +1 -1
- package/dist/{paperSettingsWidget-7766a5Fe.cjs.map → paperSettingsWidget-CJ4QFjYK.cjs.map} +1 -1
- package/dist/{paperSettingsWidget-DvtghSA5.js → paperSettingsWidget-d93s3Gsr.js} +1 -1
- package/dist/{paperSettingsWidget-DvtghSA5.js.map → paperSettingsWidget-d93s3Gsr.js.map} +1 -1
- package/dist/shell.cjs +1 -1
- package/dist/shell.mjs +2 -2
- package/dist/sidebarPortal-B2Mk9Aba.js +875 -0
- package/dist/sidebarPortal-B2Mk9Aba.js.map +1 -0
- package/dist/sidebarPortal-BCIVv4yO.cjs +3 -0
- package/dist/sidebarPortal-BCIVv4yO.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/PalettePanel-BMZ6dfI3.cjs.map +0 -1
- package/dist/PalettePanel-Cigl9i1N.js.map +0 -1
- package/dist/sidebarPortal-BN6FVwaF.js +0 -870
- package/dist/sidebarPortal-BN6FVwaF.js.map +0 -1
- package/dist/sidebarPortal-Cr-dLvA_.cjs +0 -3
- package/dist/sidebarPortal-Cr-dLvA_.cjs.map +0 -1
package/dist/canvas.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./paperSettingsWidget-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./paperSettingsWidget-CJ4QFjYK.cjs"),t=require("./sidebarPortal-BCIVv4yO.cjs");function r(i){return{book:{paper:{size:{preset:t.PaperSizePreset.CUSTOM,width:{value:50,unit:"mm"},height:{value:10,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},pages:[{grid:{colCount:3,rowCount:1,cols:{1:{value:8,unit:"mm"},2:{value:15,unit:"mm"}}},blocks:[{...e.numberInputBlock(`${i}-value`,`${i}.value`),layout:{x:0,y:0,w:1,h:1}},{id:`${i}-stepper`,kind:"stepper",layout:{x:1,y:0,w:1,h:1},props:{binding:`${i}.value`,step:1,min:0}},{...e.unitSelectBlock(`${i}-unit`,`${i}.unit`),layout:{x:2,y:0,w:1,h:1}}]}]}}}const n={size:{preset:t.PaperSizePreset.CUSTOM,width:{value:120,unit:"mm"},height:{value:8,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},o={colCount:9,rowCount:1,cols:{1:{value:8,unit:"mm"},2:{value:16,unit:"mm"},4:{value:8,unit:"mm"},5:{value:16,unit:"mm"},7:{value:8,unit:"mm"},8:{value:16,unit:"mm"}}},a={book:{paper:n,pages:[{grid:o,blocks:[{id:"margin-bulk-label",kind:"text",layout:{x:0,y:0,w:2,h:1},initValue:"一括",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{id:"margin-bulk-checkbox",kind:"checkbox",layout:{x:2,y:0,w:1,h:1},props:{binding:"margin.bulk"}},{...e.numberInputBlock("margin-top-value","margin.top.value"),layout:{x:3,y:0,w:1,h:1},hiddenBinding:"margin.bulk"},{id:"margin-top-stepper",kind:"stepper",layout:{x:4,y:0,w:1,h:1},props:{binding:"margin.top.value",step:1,min:0},hiddenBinding:"margin.bulk"},{...e.unitSelectBlock("margin-top-unit","margin.top.unit"),layout:{x:5,y:0,w:1,h:1},hiddenBinding:"margin.bulk"},{...e.numberInputBlock("margin-all-value","margin.all.value"),layout:{x:3,y:0,w:1,h:1},hiddenBinding:{path:"margin.bulk",neq:!0}},{id:"margin-all-stepper",kind:"stepper",layout:{x:4,y:0,w:1,h:1},props:{binding:"margin.all.value",step:1,min:0},hiddenBinding:{path:"margin.bulk",neq:!0}},{...e.unitSelectBlock("margin-all-unit","margin.all.unit"),layout:{x:5,y:0,w:1,h:1},hiddenBinding:{path:"margin.bulk",neq:!0}}]}]}},l={book:{paper:n,pages:[{grid:o,blocks:[{...e.numberInputBlock("margin-left-value","margin.left.value"),layout:{x:0,y:0,w:1,h:1}},{id:"margin-left-stepper",kind:"stepper",layout:{x:1,y:0,w:1,h:1},props:{binding:"margin.left.value",step:1,min:0}},{...e.unitSelectBlock("margin-left-unit","margin.left.unit"),layout:{x:2,y:0,w:1,h:1}},{...e.numberInputBlock("margin-right-value","margin.right.value"),layout:{x:6,y:0,w:1,h:1}},{id:"margin-right-stepper",kind:"stepper",layout:{x:7,y:0,w:1,h:1},props:{binding:"margin.right.value",step:1,min:0}},{...e.unitSelectBlock("margin-right-unit","margin.right.unit"),layout:{x:8,y:0,w:1,h:1}}]}]}},u={book:{paper:n,pages:[{grid:o,blocks:[{...e.numberInputBlock("margin-bottom-value","margin.bottom.value"),layout:{x:3,y:0,w:1,h:1}},{id:"margin-bottom-stepper",kind:"stepper",layout:{x:4,y:0,w:1,h:1},props:{binding:"margin.bottom.value",step:1,min:0}},{...e.unitSelectBlock("margin-bottom-unit","margin.bottom.unit"),layout:{x:5,y:0,w:1,h:1}}]}]}},p={props:{book:{paper:{size:{preset:t.PaperSizePreset.CUSTOM,width:{value:120,unit:"mm"},height:{value:24,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},pages:[{grid:{colCount:1,rowCount:3,rows:{0:{value:8,unit:"mm"},1:{value:8,unit:"mm"},2:{value:8,unit:"mm"}}},blocks:[{id:"row-bulk-top",kind:"note",layout:{x:0,y:0,w:1,h:1},behavior:{heightFit:!0},props:a},{id:"row-left-right",kind:"note",layout:{x:0,y:1,w:1,h:1},behavior:{heightFit:!0},props:l,hiddenBinding:"margin.bulk"},{id:"row-bottom",kind:"note",layout:{x:0,y:2,w:1,h:1},behavior:{heightFit:!0},props:u,hiddenBinding:"margin.bulk"}]}]}},plugins:[e.CheckboxPlugin,e.NoteBlockPlugin,e.SelectPlugin,e.StepperPlugin,e.TextPlugin]};exports.BlockBorder=e.BlockBorder;exports.BlockCanvas=e.BlockCanvas;exports.BlockContainer=e.BlockContainer;exports.BlockGuideBorder=e.BlockGuideBorder;exports.BlockLayer=e.BlockLayer;exports.BlockRenderer=e.BlockRenderer;exports.ButtonPlugin=e.ButtonPlugin;exports.ButtonRenderer=e.ButtonRenderer;exports.CheckboxRenderer=e.CheckboxRenderer;exports.DEFAULT_GUIDE_BORDER=e.DEFAULT_GUIDE_BORDER;exports.DragType=e.DragType;exports.InteractionLayer=e.InteractionLayer;exports.InteractionMode=e.InteractionMode;exports.NoteBlockPlugin=e.NoteBlockPlugin;exports.NoteBlockRenderer=e.NoteBlockRenderer;exports.PAPER_SIZE_BLOCKS=e.PAPER_SIZE_BLOCKS;exports.ResizeHandle=e.ResizeHandle;exports.SelectRenderer=e.SelectRenderer;exports.StepperPlugin=e.StepperPlugin;exports.StepperRenderer=e.StepperRenderer;exports.TextRenderer=e.TextRenderer;exports.ValidationOverlay=e.ValidationOverlay;exports.buttonActionProp=e.buttonActionProp;exports.buttonContentProp=e.buttonContentProp;exports.evaluateCheckboxValidation=e.evaluateCheckboxValidation;exports.evaluateValidation=e.evaluateValidation;exports.executeButtonAction=e.executeButtonAction;exports.fontStyleProp=e.fontStyleProp;exports.getButtonActionActive=e.getButtonActionActive;exports.getInteractionMode=e.getInteractionMode;exports.getPaperSize=e.getPaperSize;exports.gridColCountWidget=e.gridColCountWidget;exports.gridRowCountWidget=e.gridRowCountWidget;exports.hasValidationRule=e.hasValidationRule;exports.isButtonActionEnabled=e.isButtonActionEnabled;exports.numberInputBlock=e.numberInputBlock;exports.paddingProp=e.paddingProp;exports.paperOrientationWidget=e.paperOrientationWidget;exports.paperPresetSelectWidget=e.paperPresetSelectWidget;exports.paperSizeWidget=e.paperSizeWidget;exports.placeholderProp=e.placeholderProp;exports.requiredProp=e.requiredProp;exports.resolveEffectivePaper=e.resolveEffectivePaper;exports.selectConfigProp=e.selectConfigProp;exports.stepperBehaviorProp=e.stepperBehaviorProp;exports.stepperStyleProp=e.stepperStyleProp;exports.unitSelectBlock=e.unitSelectBlock;exports.useBookActionContext=e.useBookActionContext;exports.useBookBindingContext=e.useBookBindingContext;exports.useBookHistory=e.useBookHistory;exports.useInteractionState=e.useInteractionState;exports.ACTUAL_UNITS=t.ACTUAL_UNITS;exports.ALL_UNITS=t.ALL_UNITS;exports.BORDER_UNITS=t.BORDER_UNITS;exports.DEFAULT_DPI=t.DEFAULT_DPI;exports.FONT_UNITS=t.FONT_UNITS;exports.GRID_UNITS=t.GRID_UNITS;exports.HorizontalAlign=t.HorizontalAlign;exports.InputType=t.InputType;exports.PADDING_UNITS=t.PADDING_UNITS;exports.PAPER_UNITS=t.PAPER_UNITS;exports.SIZE_UNITS=t.SIZE_UNITS;exports.Units=t.Units;exports.VerticalAlign=t.VerticalAlign;exports.WhiteSpace=t.WhiteSpace;exports.WordWrap=t.WordWrap;exports.alignmentProp=t.alignmentProp;exports.checkboxStyleProp=t.checkboxStyleProp;exports.dimensionToString=t.dimensionToString;exports.isValue=t.isValue;exports.startBlockDrag=t.startBlockDrag;exports.stringToDimension=t.stringToDimension;exports.textBehaviorProp=t.textBehaviorProp;exports.textValidationProp=t.textValidationProp;exports.toMm=t.toMm;exports.toPx=t.toPx;exports.validatePage=t.validatePage;exports.validateValues=t.validateValues;exports.dimensionInputWidget=r;exports.marginSettingsWidget=p;
|
package/dist/canvas.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as a, y as e, C as r, z as u, S as l, d as s, T as m } from "./paperSettingsWidget-
|
|
2
|
-
import { A as x, E as B, F as P, G as w, h as S, H as R, B as T, I as C, J as I, K as f, L as _, M as A, O, P as W, Q as U, R as E, U as D, W as N, X as z, Y as L, Z as V, _ as F, $ as H, a0 as M, a1 as G, a2 as $, a3 as q, a4 as K, a5 as Z, a6 as J, a7 as Q, a8 as j, a9 as X, aa as Y, ab as tt, ac as at, ad as et, ae as it, af as nt, e as ot, ag as rt, ah as ut, ai as lt, b as st, a as mt, u as pt, aj as gt } from "./paperSettingsWidget-
|
|
3
|
-
import { P as i } from "./sidebarPortal-
|
|
4
|
-
import { A as ht, o as vt, B as ct, D as yt, F as kt, G as bt, H as xt, I as Bt, q as Pt, r as wt, t as St, U as Rt, V as Tt, W as Ct, v as It, w as ft, x as _t, y as At, z as Ot, C as Wt, E as Ut, J as Et, K as Dt, M as Nt, O as zt, Q as Lt, R as Vt } from "./sidebarPortal-
|
|
1
|
+
import { n as a, y as e, C as r, z as u, S as l, d as s, T as m } from "./paperSettingsWidget-d93s3Gsr.js";
|
|
2
|
+
import { A as x, E as B, F as P, G as w, h as S, H as R, B as T, I as C, J as I, K as f, L as _, M as A, O, P as W, Q as U, R as E, U as D, W as N, X as z, Y as L, Z as V, _ as F, $ as H, a0 as M, a1 as G, a2 as $, a3 as q, a4 as K, a5 as Z, a6 as J, a7 as Q, a8 as j, a9 as X, aa as Y, ab as tt, ac as at, ad as et, ae as it, af as nt, e as ot, ag as rt, ah as ut, ai as lt, b as st, a as mt, u as pt, aj as gt } from "./paperSettingsWidget-d93s3Gsr.js";
|
|
3
|
+
import { P as i } from "./sidebarPortal-B2Mk9Aba.js";
|
|
4
|
+
import { A as ht, o as vt, B as ct, D as yt, F as kt, G as bt, H as xt, I as Bt, q as Pt, r as wt, t as St, U as Rt, V as Tt, W as Ct, v as It, w as ft, x as _t, y as At, z as Ot, C as Wt, E as Ut, J as Et, K as Dt, M as Nt, O as zt, Q as Lt, R as Vt } from "./sidebarPortal-B2Mk9Aba.js";
|
|
5
5
|
function c(t) {
|
|
6
6
|
return {
|
|
7
7
|
book: {
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const i=require("./paperSettingsWidget-7766a5Fe.cjs"),p=require("react"),u=require("./sidebarPortal-Cr-dLvA_.cjs"),J=require("react-dom"),Q=require("react-dom/client"),r=require("react/jsx-runtime"),b=require("./PalettePanel-BMZ6dfI3.cjs");function ee(e){const t={};for(const o of e.properties)Object.assign(t,o.defaultProps);return t}function O(e){const t=new Set;for(const o of e){if(t.has(o.kind))throw new Error(`[createPluginRegistry] duplicate plugin kind: "${o.kind}". Each kind must be registered only once.`);t.add(o.kind)}return Object.fromEntries(e.map(o=>{if(!o.Renderer)throw new Error(`[createPluginRegistry] plugin "${o.kind}" is missing a Renderer. Ensure you are passing a full BlockPlugin.`);return[o.kind,{kind:o.kind,meta:o.meta,properties:o.properties,defaultProps:ee(o),Renderer:o.Renderer,...typeof o.migrateProps=="function"?{migrateProps:o.migrateProps}:{},...typeof o.validateProps=="function"?{validateProps:o.validateProps}:{},...typeof o.validateValue=="function"?{validateValue:o.validateValue}:{}}]}))}const te=[i.CheckboxPlugin,i.SelectPlugin,i.TextPlugin];function oe(e,t){switch(t.type){case"setSelectedBlockIds":return{...e,selectedBlockIds:t.ids};case"setPageIdx":return{...e,pageIdx:t.idx};case"setClipboard":return{...e,clipboard:t.blocks}}}const ne={selectedBlockIds:[],pageIdx:0,clipboard:[]};function ae({book:e,handleBookChange:t}){const[o,n]=p.useReducer(oe,ne),{selectedBlockIds:a,pageIdx:l}=o,v=p.useRef(e);v.current=e;const d=p.useRef(o);d.current=o;const x=p.useCallback((s,c)=>{const h=v.current,g=d.current.pageIdx,P=h.pages[g];if(!P)return;const S=P.blocks.map(z=>{const D=s[z.id];return D?{...z,...D}:z});t(i.setPage(h,g,{...P,blocks:S}),c);const w=d.current.selectedBlockIds,A=w.map(z=>{var L;const D=(L=s[z])==null?void 0:L.id;return typeof D=="string"?D:z});A.some((z,D)=>z!==w[D])&&n({type:"setSelectedBlockIds",ids:A})},[t]),m=p.useCallback(s=>{const c=v.current,h=d.current.pageIdx,g=c.pages[h];if(!g)return;const P=new Set(s),S=g.blocks.filter(w=>!P.has(w.id));t(i.setPage(c,h,{...g,blocks:S})),n({type:"setSelectedBlockIds",ids:[]})},[t]),y=p.useCallback(s=>{const c=v.current,h=d.current.pageIdx,g=c.pages[h];if(!g)return;const P=g.blocks.filter(S=>s.includes(S.id));n({type:"setClipboard",blocks:P})},[]),C=p.useCallback(s=>{const c=v.current,h=d.current.pageIdx,g=c.pages[h];if(!g)return;const P=g.blocks.filter(A=>s.includes(A.id)),S=g.grid,w=P.map(A=>({...A,id:i.createBlockId(A.kind),layout:{...A.layout,x:Math.min(A.layout.x+1,S.colCount-A.layout.w),y:Math.min(A.layout.y+1,S.rowCount-A.layout.h)}}));t(i.setPage(c,h,{...g,blocks:[...g.blocks,...w]})),n({type:"setSelectedBlockIds",ids:w.map(A=>A.id)})},[t]),f=p.useCallback(()=>{const s=d.current.clipboard;if(s.length===0)return;const c=v.current,h=d.current.pageIdx,g=c.pages[h];if(!g)return;const P=g.grid,S=s.map(w=>({...w,id:i.createBlockId(w.kind),layout:{...w.layout,x:Math.min(w.layout.x+1,P.colCount-w.layout.w),y:Math.min(w.layout.y+1,P.rowCount-w.layout.h)}}));t(i.setPage(c,h,{...g,blocks:[...g.blocks,...S]})),n({type:"setSelectedBlockIds",ids:S.map(w=>w.id)})},[t]),I=p.useCallback(()=>{var P;const s=v.current,c=d.current.pageIdx,h=s.pages[c],g={grid:h?h.grid:((P=s.pages[0])==null?void 0:P.grid)??{colCount:12,rowCount:24},blocks:[]};t(i.insertPage(s,c,g)),n({type:"setPageIdx",idx:c+1})},[t]),E=p.useCallback(()=>{const s=v.current,c=d.current.pageIdx;if(s.pages.length<=1)return;const h=i.removePage(s,c);t(h),n({type:"setPageIdx",idx:Math.min(c,h.pages.length-1)})},[t]),T=p.useMemo(()=>({paste:{execute:f,isEnabled:()=>d.current.clipboard.length>0},delete:{execute:()=>m(d.current.selectedBlockIds),isEnabled:()=>d.current.selectedBlockIds.length>0},copy:{execute:()=>y(d.current.selectedBlockIds),isEnabled:()=>d.current.selectedBlockIds.length>0},duplicate:{execute:()=>C(d.current.selectedBlockIds),isEnabled:()=>d.current.selectedBlockIds.length>0},addPage:{execute:I,isEnabled:()=>!0},deletePage:{execute:E,isEnabled:()=>v.current.pages.length>1},selectBlocks:{execute:s=>n({type:"setSelectedBlockIds",ids:s}),isEnabled:()=>!0,validatePayload:s=>Array.isArray(s)&&s.every(c=>typeof c=="string")},goToPage:{execute:s=>n({type:"setPageIdx",idx:s}),isEnabled:()=>!0,validatePayload:s=>typeof s=="number"},updateBlocks:{execute:s=>{const{updates:c,options:h}=s;x(c,h)},isEnabled:()=>!0,validatePayload:s=>typeof s=="object"&&s!==null&&"updates"in s&&typeof s.updates=="object"}}),[f,m,y,C,I,E,x]);return{editorState:p.useMemo(()=>({selectedBlockIds:a,pageIdx:l}),[a,l]),actionHandlers:T,selectedBlockIds:a}}function ie({initialBook:e,pluginRegistry:t,defaultValues:o,extra:n}){const a=p.useRef(null),{book:l,handleBookChange:v,historyActionHandlers:d}=i.useBookHistory({initialBook:e}),[x,m]=p.useState(o??{}),y=p.useCallback(s=>{s.length!==0&&m(c=>{if(!s.some(({id:P,value:S})=>S===void 0?P in c:c[P]!==S))return c;const g={...c};for(const{id:P,value:S}of s)S===void 0?delete g[P]:g[P]=S;return g})},[]),{editorState:C,actionHandlers:f}=ae({book:l,handleBookChange:v}),I={pageIdx:C.pageIdx,...n?{extra:n}:{}},E=i.useBookBindingContext(l,v,I),T=i.useBookActionContext({...d,...f});return{context:p.useMemo(()=>({book:l,onBookChange:v,pluginRegistry:t,containerRef:a,bindingContext:E,actionContext:T,values:x,onValuesChange:y,editorState:C}),[l,v,t,E,T,x,y,C])}}const k={selectAll:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z",deselectAll:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z",delete:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",copy:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z",paste:"M19 2h-4.18C14.4.84 13.3 0 12 0c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z",duplicate:"M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-1 9h-4v4h-2v-4H9V9h4V5h2v4h4v2z",undo:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z",redo:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z",prevPage:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z",nextPage:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z",addPage:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z",deletePage:"M19 13H5v-2h14v2z"},_={value:2,unit:"mm"};function B(e,t,o){return{iconPath:e,label:"",action:t,...o?{title:o}:{},top:_,right:_,bottom:_,left:_}}function V(e="canvas-actions"){return{props:{book:{paper:{size:{preset:u.PaperSizePreset.CUSTOM,width:{value:160,unit:"mm"},height:{value:20,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}}},pages:[{grid:{colCount:8,rowCount:1},blocks:[{id:`${e}-select-all`,kind:"button",layout:{x:0,y:0,w:1,h:1},props:B(k.selectAll,"select_all","すべて選択")},{id:`${e}-deselect-all`,kind:"button",layout:{x:1,y:0,w:1,h:1},props:B(k.deselectAll,"deselect_all","選択を解除")},{id:`${e}-delete`,kind:"button",layout:{x:2,y:0,w:1,h:1},props:B(k.delete,"delete","削除 (Delete / Backspace)")},{id:`${e}-copy`,kind:"button",layout:{x:3,y:0,w:1,h:1},props:B(k.copy,"copy","コピー (Ctrl+C / Cmd+C)")},{id:`${e}-paste`,kind:"button",layout:{x:4,y:0,w:1,h:1},props:B(k.paste,"paste","貼り付け (Ctrl+V / Cmd+V)")},{id:`${e}-duplicate`,kind:"button",layout:{x:5,y:0,w:1,h:1},props:B(k.duplicate,"duplicate","複製 (Ctrl+D / Cmd+D)")},{id:`${e}-undo`,kind:"button",layout:{x:6,y:0,w:1,h:1},props:B(k.undo,"undo","元に戻す (Ctrl+Z / Cmd+Z)")},{id:`${e}-redo`,kind:"button",layout:{x:7,y:0,w:1,h:1},props:B(k.redo,"redo","やり直し (Ctrl+Y / Cmd+Y)")}]}]}},plugins:[i.ButtonPlugin]}}const re=V();function H(e="clipboard"){return{props:{book:{paper:{size:{preset:u.PaperSizePreset.CUSTOM,width:{value:60,unit:"mm"},height:{value:20,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}}},pages:[{grid:{colCount:3,rowCount:1},blocks:[{id:`${e}-copy`,kind:"button",layout:{x:0,y:0,w:1,h:1},props:B(k.copy,"copy")},{id:`${e}-paste`,kind:"button",layout:{x:1,y:0,w:1,h:1},props:B(k.paste,"paste")},{id:`${e}-duplicate`,kind:"button",layout:{x:2,y:0,w:1,h:1},props:B(k.duplicate,"duplicate")}]}]}},plugins:[i.ButtonPlugin]}}const le=H();function W(e="history"){return{props:{book:{paper:{size:{preset:u.PaperSizePreset.CUSTOM,width:{value:40,unit:"mm"},height:{value:20,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}}},pages:[{grid:{colCount:2,rowCount:1},blocks:[{id:`${e}-undo`,kind:"button",layout:{x:0,y:0,w:1,h:1},props:B(k.undo,"undo")},{id:`${e}-redo`,kind:"button",layout:{x:1,y:0,w:1,h:1},props:B(k.redo,"redo")}]}]}},plugins:[i.ButtonPlugin]}}const se=W(),j={size:{preset:u.PaperSizePreset.CUSTOM},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},ce={margin:j.margin,autoHeight:j.autoHeight,autoWidth:j.autoWidth},de={props:{book:{paper:{...ce,size:{preset:u.PaperSizePreset.CUSTOM,width:{value:160,unit:"mm"},height:{value:8,unit:"mm"}}},pages:[{grid:{colCount:12,rowCount:1,cols:{2:{value:8,unit:"mm"},5:{value:8,unit:"mm"},8:{value:8,unit:"mm"},11:{value:8,unit:"mm"}}},blocks:[{id:"layout-x-label",kind:"text",layout:{x:0,y:0,w:1,h:1},initValue:"X",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...i.numberInputBlock("layout-x-value","layout.x"),layout:{x:1,y:0,w:1,h:1}},{id:"layout-x-stepper",kind:"stepper",layout:{x:2,y:0,w:1,h:1},props:{binding:"layout.x",step:1,min:0}},{id:"layout-y-label",kind:"text",layout:{x:3,y:0,w:1,h:1},initValue:"Y",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...i.numberInputBlock("layout-y-value","layout.y"),layout:{x:4,y:0,w:1,h:1}},{id:"layout-y-stepper",kind:"stepper",layout:{x:5,y:0,w:1,h:1},props:{binding:"layout.y",step:1,min:0}},{id:"layout-w-label",kind:"text",layout:{x:6,y:0,w:1,h:1},initValue:"W",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...i.numberInputBlock("layout-w-value","layout.w"),layout:{x:7,y:0,w:1,h:1}},{id:"layout-w-stepper",kind:"stepper",layout:{x:8,y:0,w:1,h:1},props:{binding:"layout.w",step:1,min:1}},{id:"layout-h-label",kind:"text",layout:{x:9,y:0,w:1,h:1},initValue:"H",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...i.numberInputBlock("layout-h-value","layout.h"),layout:{x:10,y:0,w:1,h:1}},{id:"layout-h-stepper",kind:"stepper",layout:{x:11,y:0,w:1,h:1},props:{binding:"layout.h",step:1,min:1}}]}]}},plugins:[i.TextPlugin,i.StepperPlugin]};function $(e){const{pageIdx:t,pageCount:o}=e,n=t!==void 0?String(t+1):"—",a=o!==void 0?String(o):"—";return{props:{book:{paper:{size:{preset:u.PaperSizePreset.CUSTOM,width:{value:130,unit:"mm"},height:{value:20,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}}},pages:[{grid:{colCount:7,rowCount:1,cols:{2:{value:10,unit:"mm"}}},blocks:[{id:"prev-page",kind:"button",layout:{x:0,y:0,w:1,h:1},props:{iconPath:k.prevPage,label:"",action:"prev_page"}},{id:"page-current",kind:"text",layout:{x:1,y:0,w:1,h:1},behavior:{readOnly:!0},initValue:n,props:{horizontal:"right",vertical:"center",fontSize:{value:25,unit:"pt"}}},{id:"page-separator",kind:"text",layout:{x:2,y:0,w:1,h:1},behavior:{readOnly:!0},initValue:"/",props:{horizontal:"center",vertical:"center",fontSize:{value:25,unit:"pt"}}},{id:"page-total",kind:"text",layout:{x:3,y:0,w:1,h:1},behavior:{readOnly:!0},initValue:a,props:{horizontal:"left",vertical:"center",fontSize:{value:25,unit:"pt"}}},{id:"next-page",kind:"button",layout:{x:4,y:0,w:1,h:1},props:{iconPath:k.nextPage,label:"",action:"next_page"}},{id:"add-page",kind:"button",layout:{x:5,y:0,w:1,h:1},props:{iconPath:k.addPage,label:"",action:"add_page"}},{id:"delete-page",kind:"button",layout:{x:6,y:0,w:1,h:1},props:{iconPath:k.deletePage,label:"",action:"delete_page"}}]}]}},plugins:[i.ButtonPlugin,i.TextPlugin]}}const ue=$({});function F(e="selection"){return{props:{book:{paper:{size:{preset:u.PaperSizePreset.CUSTOM,width:{value:60,unit:"mm"},height:{value:20,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}}},pages:[{grid:{colCount:3,rowCount:1},blocks:[{id:`${e}-select-all`,kind:"button",layout:{x:0,y:0,w:1,h:1},props:B(k.selectAll,"select_all")},{id:`${e}-deselect-all`,kind:"button",layout:{x:1,y:0,w:1,h:1},props:B(k.deselectAll,"deselect_all")},{id:`${e}-delete`,kind:"button",layout:{x:2,y:0,w:1,h:1},props:B(k.delete,"delete")}]}]}},plugins:[i.ButtonPlugin]}}const pe=F(),U=({sections:e=[],className:t,style:o})=>r.jsx("div",{className:`${b.styles.container}${t?` ${t}`:""}`,style:o,"data-testid":"action-bar",children:e.map((n,a)=>{const l=p.isValidElement(n)&&n.key!=null?n.key:`section-${a}`;return r.jsxs(p.Fragment,{children:[a>0&&r.jsx(b.ActionBarDivider,{}),r.jsx("div",{className:b.styles.section,children:n})]},l)})});U.displayName="ActionBar";const ge="_printContainer_e2bnt_1",me="_pageBreak_e2bnt_6",N={printContainer:ge,pageBreak:me},G=p.memo(({page:e,paper:t,values:o,pluginRegistry:n})=>{const{paperPx:a,getBlockRectPx:l}=u.useGridCalc(t,e.grid,u.DEFAULT_DPI),v=o?{get:x=>o[x]??null,set:()=>{}}:void 0,d=e.blocks.filter(x=>!i.evalHiddenBinding(x.hiddenBinding,v));return r.jsx("div",{style:{position:"relative",width:`${a.canvas.width}px`,height:`${a.canvas.height}px`,backgroundColor:"#fff"},children:r.jsx(i.BlockLayer,{blocks:d,pluginRegistry:n,mode:u.NoteMode.VIEW,values:o??{},blockDefaults:e.blockDefaults,getBlockRectPx:l,showGuides:!1,showBorder:!0})})});G.displayName="PrintPage";const q=p.forwardRef(({book:e,values:t,pluginRegistry:o,printSettings:n,className:a,style:l},v)=>{const d=i.resolveEffectivePaper(e,n),x=i.buildPageCss(d,n==null?void 0:n.margin);return p.useEffect(()=>{var C,f;(C=document.getElementById("printable-note-page-style"))==null||C.remove(),(f=document.getElementById("tatamicks-book-page-style"))==null||f.remove();const m=document.createElement("style");m.id="printable-note-page-style",m.textContent=x,document.head.appendChild(m);const y=document.createElement("style");return y.id="tatamicks-book-page-style",y.textContent=x,document.head.appendChild(y),()=>{var I,E;(I=document.getElementById("printable-note-page-style"))==null||I.remove(),(E=document.getElementById("tatamicks-book-page-style"))==null||E.remove()}},[x]),r.jsx("div",{ref:v,className:[N.printContainer,a].filter(Boolean).join(" "),style:l,children:e.pages.map((m,y)=>{const C=m.id??(m.blocks.map(f=>f.id).join("_")||`page-${y}`);return r.jsx("div",{className:y<e.pages.length-1?N.pageBreak:void 0,children:r.jsx(G,{page:m,paper:d,values:t,pluginRegistry:o})},C)})})});q.displayName="NotePrint";const ye=p.memo(q);function he(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function be(e,t){const o=document.title,n=document.createElement("iframe");n.style.cssText="position:fixed;top:0;left:0;width:100%;height:100%;visibility:hidden;z-index:-9999;border:none;",document.body.appendChild(n);const a=n.contentWindow,l=n.contentDocument??(a==null?void 0:a.document);if(!l||!a){document.body.removeChild(n);return}const v=Array.from(document.querySelectorAll("style")).map(y=>y.outerHTML).join(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const i=require("./paperSettingsWidget-CJ4QFjYK.cjs"),p=require("react"),u=require("./sidebarPortal-BCIVv4yO.cjs"),J=require("react-dom"),Q=require("react-dom/client"),r=require("react/jsx-runtime"),b=require("./PalettePanel-0cFP3tbA.cjs");function ee(e){const t={};for(const o of e.properties)Object.assign(t,o.defaultProps);return t}function O(e){const t=new Set;for(const o of e){if(t.has(o.kind))throw new Error(`[createPluginRegistry] duplicate plugin kind: "${o.kind}". Each kind must be registered only once.`);t.add(o.kind)}return Object.fromEntries(e.map(o=>{if(!o.Renderer)throw new Error(`[createPluginRegistry] plugin "${o.kind}" is missing a Renderer. Ensure you are passing a full BlockPlugin.`);return[o.kind,{kind:o.kind,meta:o.meta,properties:o.properties,defaultProps:ee(o),Renderer:o.Renderer,...typeof o.migrateProps=="function"?{migrateProps:o.migrateProps}:{},...typeof o.validateProps=="function"?{validateProps:o.validateProps}:{},...typeof o.validateValue=="function"?{validateValue:o.validateValue}:{}}]}))}const te=[i.CheckboxPlugin,i.SelectPlugin,i.TextPlugin];function oe(e,t){switch(t.type){case"setSelectedBlockIds":return{...e,selectedBlockIds:t.ids};case"setPageIdx":return{...e,pageIdx:t.idx};case"setClipboard":return{...e,clipboard:t.blocks}}}const ne={selectedBlockIds:[],pageIdx:0,clipboard:[]};function ae({book:e,handleBookChange:t}){const[o,n]=p.useReducer(oe,ne),{selectedBlockIds:a,pageIdx:l}=o,v=p.useRef(e);v.current=e;const d=p.useRef(o);d.current=o;const x=p.useCallback((s,c)=>{const h=v.current,g=d.current.pageIdx,P=h.pages[g];if(!P)return;const S=P.blocks.map(z=>{const D=s[z.id];return D?{...z,...D}:z});t(i.setPage(h,g,{...P,blocks:S}),c);const w=d.current.selectedBlockIds,A=w.map(z=>{var L;const D=(L=s[z])==null?void 0:L.id;return typeof D=="string"?D:z});A.some((z,D)=>z!==w[D])&&n({type:"setSelectedBlockIds",ids:A})},[t]),m=p.useCallback(s=>{const c=v.current,h=d.current.pageIdx,g=c.pages[h];if(!g)return;const P=new Set(s),S=g.blocks.filter(w=>!P.has(w.id));t(i.setPage(c,h,{...g,blocks:S})),n({type:"setSelectedBlockIds",ids:[]})},[t]),y=p.useCallback(s=>{const c=v.current,h=d.current.pageIdx,g=c.pages[h];if(!g)return;const P=g.blocks.filter(S=>s.includes(S.id));n({type:"setClipboard",blocks:P})},[]),C=p.useCallback(s=>{const c=v.current,h=d.current.pageIdx,g=c.pages[h];if(!g)return;const P=g.blocks.filter(A=>s.includes(A.id)),S=g.grid,w=P.map(A=>({...A,id:i.createBlockId(A.kind),layout:{...A.layout,x:Math.min(A.layout.x+1,S.colCount-A.layout.w),y:Math.min(A.layout.y+1,S.rowCount-A.layout.h)}}));t(i.setPage(c,h,{...g,blocks:[...g.blocks,...w]})),n({type:"setSelectedBlockIds",ids:w.map(A=>A.id)})},[t]),f=p.useCallback(()=>{const s=d.current.clipboard;if(s.length===0)return;const c=v.current,h=d.current.pageIdx,g=c.pages[h];if(!g)return;const P=g.grid,S=s.map(w=>({...w,id:i.createBlockId(w.kind),layout:{...w.layout,x:Math.min(w.layout.x+1,P.colCount-w.layout.w),y:Math.min(w.layout.y+1,P.rowCount-w.layout.h)}}));t(i.setPage(c,h,{...g,blocks:[...g.blocks,...S]})),n({type:"setSelectedBlockIds",ids:S.map(w=>w.id)})},[t]),I=p.useCallback(()=>{var P;const s=v.current,c=d.current.pageIdx,h=s.pages[c],g={grid:h?h.grid:((P=s.pages[0])==null?void 0:P.grid)??{colCount:12,rowCount:24},blocks:[]};t(i.insertPage(s,c,g)),n({type:"setPageIdx",idx:c+1})},[t]),E=p.useCallback(()=>{const s=v.current,c=d.current.pageIdx;if(s.pages.length<=1)return;const h=i.removePage(s,c);t(h),n({type:"setPageIdx",idx:Math.min(c,h.pages.length-1)})},[t]),T=p.useMemo(()=>({paste:{execute:f,isEnabled:()=>d.current.clipboard.length>0},delete:{execute:()=>m(d.current.selectedBlockIds),isEnabled:()=>d.current.selectedBlockIds.length>0},copy:{execute:()=>y(d.current.selectedBlockIds),isEnabled:()=>d.current.selectedBlockIds.length>0},duplicate:{execute:()=>C(d.current.selectedBlockIds),isEnabled:()=>d.current.selectedBlockIds.length>0},addPage:{execute:I,isEnabled:()=>!0},deletePage:{execute:E,isEnabled:()=>v.current.pages.length>1},selectBlocks:{execute:s=>n({type:"setSelectedBlockIds",ids:s}),isEnabled:()=>!0,validatePayload:s=>Array.isArray(s)&&s.every(c=>typeof c=="string")},goToPage:{execute:s=>n({type:"setPageIdx",idx:s}),isEnabled:()=>!0,validatePayload:s=>typeof s=="number"},updateBlocks:{execute:s=>{const{updates:c,options:h}=s;x(c,h)},isEnabled:()=>!0,validatePayload:s=>typeof s=="object"&&s!==null&&"updates"in s&&typeof s.updates=="object"}}),[f,m,y,C,I,E,x]);return{editorState:p.useMemo(()=>({selectedBlockIds:a,pageIdx:l}),[a,l]),actionHandlers:T,selectedBlockIds:a}}function ie({initialBook:e,pluginRegistry:t,defaultValues:o,extra:n}){const a=p.useRef(null),{book:l,handleBookChange:v,historyActionHandlers:d}=i.useBookHistory({initialBook:e}),[x,m]=p.useState(o??{}),y=p.useCallback(s=>{s.length!==0&&m(c=>{if(!s.some(({id:P,value:S})=>S===void 0?P in c:c[P]!==S))return c;const g={...c};for(const{id:P,value:S}of s)S===void 0?delete g[P]:g[P]=S;return g})},[]),{editorState:C,actionHandlers:f}=ae({book:l,handleBookChange:v}),I={pageIdx:C.pageIdx,...n?{extra:n}:{}},E=i.useBookBindingContext(l,v,I),T=i.useBookActionContext({...d,...f});return{context:p.useMemo(()=>({book:l,onBookChange:v,pluginRegistry:t,containerRef:a,bindingContext:E,actionContext:T,values:x,onValuesChange:y,editorState:C}),[l,v,t,E,T,x,y,C])}}const k={selectAll:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z",deselectAll:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z",delete:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",copy:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z",paste:"M19 2h-4.18C14.4.84 13.3 0 12 0c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z",duplicate:"M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-1 9h-4v4h-2v-4H9V9h4V5h2v4h4v2z",undo:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z",redo:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z",prevPage:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z",nextPage:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z",addPage:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z",deletePage:"M19 13H5v-2h14v2z"},_={value:2,unit:"mm"};function B(e,t,o){return{iconPath:e,label:"",action:t,...o?{title:o}:{},top:_,right:_,bottom:_,left:_}}function V(e="canvas-actions"){return{props:{book:{paper:{size:{preset:u.PaperSizePreset.CUSTOM,width:{value:160,unit:"mm"},height:{value:20,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}}},pages:[{grid:{colCount:8,rowCount:1},blocks:[{id:`${e}-select-all`,kind:"button",layout:{x:0,y:0,w:1,h:1},props:B(k.selectAll,"select_all","すべて選択")},{id:`${e}-deselect-all`,kind:"button",layout:{x:1,y:0,w:1,h:1},props:B(k.deselectAll,"deselect_all","選択を解除")},{id:`${e}-delete`,kind:"button",layout:{x:2,y:0,w:1,h:1},props:B(k.delete,"delete","削除 (Delete / Backspace)")},{id:`${e}-copy`,kind:"button",layout:{x:3,y:0,w:1,h:1},props:B(k.copy,"copy","コピー (Ctrl+C / Cmd+C)")},{id:`${e}-paste`,kind:"button",layout:{x:4,y:0,w:1,h:1},props:B(k.paste,"paste","貼り付け (Ctrl+V / Cmd+V)")},{id:`${e}-duplicate`,kind:"button",layout:{x:5,y:0,w:1,h:1},props:B(k.duplicate,"duplicate","複製 (Ctrl+D / Cmd+D)")},{id:`${e}-undo`,kind:"button",layout:{x:6,y:0,w:1,h:1},props:B(k.undo,"undo","元に戻す (Ctrl+Z / Cmd+Z)")},{id:`${e}-redo`,kind:"button",layout:{x:7,y:0,w:1,h:1},props:B(k.redo,"redo","やり直し (Ctrl+Y / Cmd+Y)")}]}]}},plugins:[i.ButtonPlugin]}}const re=V();function H(e="clipboard"){return{props:{book:{paper:{size:{preset:u.PaperSizePreset.CUSTOM,width:{value:60,unit:"mm"},height:{value:20,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}}},pages:[{grid:{colCount:3,rowCount:1},blocks:[{id:`${e}-copy`,kind:"button",layout:{x:0,y:0,w:1,h:1},props:B(k.copy,"copy")},{id:`${e}-paste`,kind:"button",layout:{x:1,y:0,w:1,h:1},props:B(k.paste,"paste")},{id:`${e}-duplicate`,kind:"button",layout:{x:2,y:0,w:1,h:1},props:B(k.duplicate,"duplicate")}]}]}},plugins:[i.ButtonPlugin]}}const le=H();function W(e="history"){return{props:{book:{paper:{size:{preset:u.PaperSizePreset.CUSTOM,width:{value:40,unit:"mm"},height:{value:20,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}}},pages:[{grid:{colCount:2,rowCount:1},blocks:[{id:`${e}-undo`,kind:"button",layout:{x:0,y:0,w:1,h:1},props:B(k.undo,"undo")},{id:`${e}-redo`,kind:"button",layout:{x:1,y:0,w:1,h:1},props:B(k.redo,"redo")}]}]}},plugins:[i.ButtonPlugin]}}const se=W(),j={size:{preset:u.PaperSizePreset.CUSTOM},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},ce={margin:j.margin,autoHeight:j.autoHeight,autoWidth:j.autoWidth},de={props:{book:{paper:{...ce,size:{preset:u.PaperSizePreset.CUSTOM,width:{value:160,unit:"mm"},height:{value:8,unit:"mm"}}},pages:[{grid:{colCount:12,rowCount:1,cols:{2:{value:8,unit:"mm"},5:{value:8,unit:"mm"},8:{value:8,unit:"mm"},11:{value:8,unit:"mm"}}},blocks:[{id:"layout-x-label",kind:"text",layout:{x:0,y:0,w:1,h:1},initValue:"X",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...i.numberInputBlock("layout-x-value","layout.x"),layout:{x:1,y:0,w:1,h:1}},{id:"layout-x-stepper",kind:"stepper",layout:{x:2,y:0,w:1,h:1},props:{binding:"layout.x",step:1,min:0}},{id:"layout-y-label",kind:"text",layout:{x:3,y:0,w:1,h:1},initValue:"Y",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...i.numberInputBlock("layout-y-value","layout.y"),layout:{x:4,y:0,w:1,h:1}},{id:"layout-y-stepper",kind:"stepper",layout:{x:5,y:0,w:1,h:1},props:{binding:"layout.y",step:1,min:0}},{id:"layout-w-label",kind:"text",layout:{x:6,y:0,w:1,h:1},initValue:"W",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...i.numberInputBlock("layout-w-value","layout.w"),layout:{x:7,y:0,w:1,h:1}},{id:"layout-w-stepper",kind:"stepper",layout:{x:8,y:0,w:1,h:1},props:{binding:"layout.w",step:1,min:1}},{id:"layout-h-label",kind:"text",layout:{x:9,y:0,w:1,h:1},initValue:"H",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...i.numberInputBlock("layout-h-value","layout.h"),layout:{x:10,y:0,w:1,h:1}},{id:"layout-h-stepper",kind:"stepper",layout:{x:11,y:0,w:1,h:1},props:{binding:"layout.h",step:1,min:1}}]}]}},plugins:[i.TextPlugin,i.StepperPlugin]};function $(e){const{pageIdx:t,pageCount:o}=e,n=t!==void 0?String(t+1):"—",a=o!==void 0?String(o):"—";return{props:{book:{paper:{size:{preset:u.PaperSizePreset.CUSTOM,width:{value:130,unit:"mm"},height:{value:20,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}}},pages:[{grid:{colCount:7,rowCount:1,cols:{2:{value:10,unit:"mm"}}},blocks:[{id:"prev-page",kind:"button",layout:{x:0,y:0,w:1,h:1},props:{iconPath:k.prevPage,label:"",action:"prev_page"}},{id:"page-current",kind:"text",layout:{x:1,y:0,w:1,h:1},behavior:{readOnly:!0},initValue:n,props:{horizontal:"right",vertical:"center",fontSize:{value:25,unit:"pt"}}},{id:"page-separator",kind:"text",layout:{x:2,y:0,w:1,h:1},behavior:{readOnly:!0},initValue:"/",props:{horizontal:"center",vertical:"center",fontSize:{value:25,unit:"pt"}}},{id:"page-total",kind:"text",layout:{x:3,y:0,w:1,h:1},behavior:{readOnly:!0},initValue:a,props:{horizontal:"left",vertical:"center",fontSize:{value:25,unit:"pt"}}},{id:"next-page",kind:"button",layout:{x:4,y:0,w:1,h:1},props:{iconPath:k.nextPage,label:"",action:"next_page"}},{id:"add-page",kind:"button",layout:{x:5,y:0,w:1,h:1},props:{iconPath:k.addPage,label:"",action:"add_page"}},{id:"delete-page",kind:"button",layout:{x:6,y:0,w:1,h:1},props:{iconPath:k.deletePage,label:"",action:"delete_page"}}]}]}},plugins:[i.ButtonPlugin,i.TextPlugin]}}const ue=$({});function F(e="selection"){return{props:{book:{paper:{size:{preset:u.PaperSizePreset.CUSTOM,width:{value:60,unit:"mm"},height:{value:20,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}}},pages:[{grid:{colCount:3,rowCount:1},blocks:[{id:`${e}-select-all`,kind:"button",layout:{x:0,y:0,w:1,h:1},props:B(k.selectAll,"select_all")},{id:`${e}-deselect-all`,kind:"button",layout:{x:1,y:0,w:1,h:1},props:B(k.deselectAll,"deselect_all")},{id:`${e}-delete`,kind:"button",layout:{x:2,y:0,w:1,h:1},props:B(k.delete,"delete")}]}]}},plugins:[i.ButtonPlugin]}}const pe=F(),U=({sections:e=[],className:t,style:o})=>r.jsx("div",{className:`${b.styles.container}${t?` ${t}`:""}`,style:o,"data-testid":"action-bar",children:e.map((n,a)=>{const l=p.isValidElement(n)&&n.key!=null?n.key:`section-${a}`;return r.jsxs(p.Fragment,{children:[a>0&&r.jsx(b.ActionBarDivider,{}),r.jsx("div",{className:b.styles.section,children:n})]},l)})});U.displayName="ActionBar";const ge="_printContainer_e2bnt_1",me="_pageBreak_e2bnt_6",N={printContainer:ge,pageBreak:me},G=p.memo(({page:e,paper:t,values:o,pluginRegistry:n})=>{const{paperPx:a,getBlockRectPx:l}=u.useGridCalc(t,e.grid,u.DEFAULT_DPI),v=o?{get:x=>o[x]??null,set:()=>{}}:void 0,d=e.blocks.filter(x=>!i.evalHiddenBinding(x.hiddenBinding,v));return r.jsx("div",{style:{position:"relative",width:`${a.canvas.width}px`,height:`${a.canvas.height}px`,backgroundColor:"#fff"},children:r.jsx(i.BlockLayer,{blocks:d,pluginRegistry:n,mode:u.NoteMode.VIEW,values:o??{},blockDefaults:e.blockDefaults,getBlockRectPx:l,showGuides:!1,showBorder:!0})})});G.displayName="PrintPage";const q=p.forwardRef(({book:e,values:t,pluginRegistry:o,printSettings:n,className:a,style:l},v)=>{const d=i.resolveEffectivePaper(e,n),x=i.buildPageCss(d,n==null?void 0:n.margin);return p.useEffect(()=>{var C,f;(C=document.getElementById("printable-note-page-style"))==null||C.remove(),(f=document.getElementById("tatamicks-book-page-style"))==null||f.remove();const m=document.createElement("style");m.id="printable-note-page-style",m.textContent=x,document.head.appendChild(m);const y=document.createElement("style");return y.id="tatamicks-book-page-style",y.textContent=x,document.head.appendChild(y),()=>{var I,E;(I=document.getElementById("printable-note-page-style"))==null||I.remove(),(E=document.getElementById("tatamicks-book-page-style"))==null||E.remove()}},[x]),r.jsx("div",{ref:v,className:[N.printContainer,a].filter(Boolean).join(" "),style:l,children:e.pages.map((m,y)=>{const C=m.id??(m.blocks.map(f=>f.id).join("_")||`page-${y}`);return r.jsx("div",{className:y<e.pages.length-1?N.pageBreak:void 0,children:r.jsx(G,{page:m,paper:d,values:t,pluginRegistry:o})},C)})})});q.displayName="NotePrint";const ye=p.memo(q);function he(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function be(e,t){const o=document.title,n=document.createElement("iframe");n.style.cssText="position:fixed;top:0;left:0;width:100%;height:100%;visibility:hidden;z-index:-9999;border:none;",document.body.appendChild(n);const a=n.contentWindow,l=n.contentDocument??(a==null?void 0:a.document);if(!l||!a){document.body.removeChild(n);return}const v=Array.from(document.querySelectorAll("style")).map(y=>y.outerHTML).join(`
|
|
2
2
|
`),d=Array.from(document.querySelectorAll('link[rel="stylesheet"]')).map(y=>y.outerHTML).join(`
|
|
3
3
|
`),x=e.innerHTML;l.open(),l.write(`<!DOCTYPE html><html><head><meta charset="utf-8" /><title>${he(o)}</title>${d}${v}<style>*{-webkit-print-color-adjust:exact!important;print-color-adjust:exact!important;}</style></head><body>${x}</body></html>`),l.close();const m=()=>{document.body.contains(n)&&document.body.removeChild(n)};a.addEventListener("afterprint",()=>{m()}),setTimeout(()=>{a.focus(),a.print()},0)}function ve(e,t,o,n){const a=document.createElement("div");a.style.cssText="position:absolute;top:-9999px;left:-9999px;",document.body.appendChild(a);const l=Q.createRoot(a);J.flushSync(()=>{l.render(p.createElement(ye,{book:e,values:t,pluginRegistry:o,printSettings:n}))}),be(a),l.unmount(),document.body.removeChild(a)}function Z(e,t){ve(e.book,e.values,e.pluginRegistry,t)}const Y=({pageIdx:e,pageCount:t,onPageChange:o,onAddPage:n,onDeletePage:a,canDeletePage:l=!0})=>r.jsxs(r.Fragment,{children:[r.jsx(b.IconActionButton,{icon:r.jsx(b.ChevronLeftIcon,{"aria-hidden":"true"}),label:"前のページへ",title:"前のページへ",onClick:()=>o(Math.max(0,e-1)),disabled:e===0,preventFocusOnMouseDown:!0}),r.jsxs("span",{className:b.styles.sectionLabel,children:[e+1," / ",t]}),r.jsx(b.IconActionButton,{icon:r.jsx(b.ChevronRightIcon,{"aria-hidden":"true"}),label:"次のページへ",title:"次のページへ",onClick:()=>o(Math.min(t-1,e+1)),disabled:e>=t-1,preventFocusOnMouseDown:!0}),n!==void 0&&r.jsx(b.IconActionButton,{icon:r.jsx(b.AddPageIcon,{"aria-hidden":"true"}),label:"ページを追加",title:"ページを追加",onClick:n,preventFocusOnMouseDown:!0}),a!==void 0&&r.jsx(b.IconActionButton,{icon:r.jsx(b.DeletePageIcon,{"aria-hidden":"true"}),label:"ページを削除",title:"ページを削除",onClick:a,disabled:!l,preventFocusOnMouseDown:!0})]});Y.displayName="PageNavigationSection";function Pe({context:e,onActionFeedback:t,onPrint:o}){const{actionContext:n}=e,{book:a,onBookChange:l}=e,d=e.editorState.pageIdx,x=a.pages[d]??a.pages[0],m=[r.jsx(b.CanvasActionSection,{actionContext:n,onActionFeedback:t,onPrint:o??(()=>Z(e))},"canvas"),r.jsx(b.PaperSettingsSection,{paper:a.paper,onPaperChange:y=>l({...a,paper:y})},"paper"),r.jsx(b.GridSettingsSection,{grid:x.grid,onGridChange:y=>{const C=a.pages.map((f,I)=>I===d?{...f,grid:y}:f);l({...a,pages:C})}},"grid")];return m.push(r.jsx(Y,{pageIdx:d,pageCount:a.pages.length,onPageChange:y=>n.execute("goToPage",y),onAddPage:()=>n.execute("addPage"),onDeletePage:()=>n.execute("deletePage"),canDeletePage:a.pages.length>1},"page-nav")),m}const K=({context:e,gridSize:t,isDragging:o,zIndex:n,onActionFeedback:a})=>{const{book:l,containerRef:v}=e,d=e.editorState,x=p.useRef(null),m=d.selectedBlockIds??[],y=p.useMemo(()=>{const f=new Set(l.pages.flatMap(I=>I.blocks.map(E=>E.id)));return m.filter(I=>f.has(I))},[m,l]),C=b.useSelectionBounds(v??x,y)??null;return r.jsx(b.SelectionActionBarOverlay,{selectionBoundingBox:C,isDragging:o,zIndex:n,children:r.jsx(b.SelectionActionBar,{items:b.getDefaultSelectionActionBarItems({context:e,gridSize:t,onActionFeedback:a}),onPointerDown:f=>f.stopPropagation()})})};K.displayName="DefaultSelectionActionBarOverlay";function xe({context:e,gridSize:t,onBlockHover:o,onBlockDragChange:n,onActionFeedback:a}){return[{value:"block",label:"ブロック",content:(e.editorState.selectedBlockIds??[]).length>0?r.jsx(b.DefaultBlockPropertyPanel,{context:e,gridSize:t}):r.jsx(b.PalettePanel,{context:e})},{value:"canvas",label:"キャンバス",content:r.jsx(b.DefaultCanvasPanel,{context:e,onBlockHover:o,onBlockDragChange:n,onActionFeedback:a})},{value:"other",label:"その他",content:r.jsx(b.OtherPanel,{context:e})}]}const ke="_container_ymana_1",fe="_tabHeader_ymana_12",Se="_tabContent_ymana_19",R={container:ke,tabHeader:fe,tabContent:Se},X=({tabs:e,defaultTab:t,className:o})=>{var a;const n=t??((a=e[0])==null?void 0:a.value)??"";return r.jsx("div",{className:`${R.container} ${o||""}`,...u.SIDEBAR_PORTAL_PROPS,children:r.jsxs(b.Tabs,{defaultValue:n,variant:"default",children:[r.jsx(b.TabsList,{className:R.tabHeader,children:e.map(l=>r.jsx(b.TabsTrigger,{value:l.value,children:l.label},l.value))}),e.map(l=>r.jsx(b.TabsContent,{value:l.value,className:R.tabContent,children:l.content},l.value))]})})};X.displayName="Sidebar";const Ce={selectedBlockIds:[],pageIdx:0};function we({label:e,widget:t,extraPlugins:o,position:n,isDragging:a,onTitlePointerDown:l,onClose:v,onContainerPointerDown:d,style:x,context:m}){const y=p.useMemo(()=>O([...t.plugins,...o??[]]),[t.plugins,o]),C=p.useRef(null),f=p.useMemo(()=>({get:c=>(m.book,m.bindingContext.get(c)),set:(c,h)=>m.bindingContext.set(c,h)}),[m.bindingContext,m.book]),I=p.useMemo(()=>({book:t.props.book,onBookChange:()=>{},pluginRegistry:y,containerRef:C,bindingContext:f,actionContext:m.actionContext,editorState:Ce,values:{}}),[t.props.book,y,f,m.actionContext]),[E,T]=p.useState(.5),M=p.useRef({x:0,zoom:.5}),s=c=>{c.preventDefault(),c.stopPropagation(),M.current={x:c.clientX,zoom:E};const h=P=>{const S=P.clientX-M.current.x;T(Math.max(.25,Math.min(2,M.current.zoom+S/400)))},g=()=>{window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",g)};window.addEventListener("pointermove",h),window.addEventListener("pointerup",g)};return r.jsxs("div",{onPointerDown:d,...u.SIDEBAR_PORTAL_PROPS,style:{position:"fixed",left:n.x,top:n.y,zIndex:a?375e4:37e5,background:"#fff",border:"1px solid #d1d5db",borderRadius:6,boxShadow:a?"0 8px 24px rgba(0,0,0,0.2)":"0 2px 8px rgba(0,0,0,0.12)",...x},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"3px 4px 3px 8px",background:"#f9fafb",borderBottom:"1px solid #e5e7eb",borderRadius:"6px 6px 0 0",cursor:"move",userSelect:"none",gap:4},onPointerDown:l,children:[r.jsx("span",{style:{fontSize:11,color:"#555",whiteSpace:"nowrap"},children:e}),r.jsx("button",{type:"button",onPointerDown:c=>c.stopPropagation(),onClick:v,style:{background:"none",border:"none",cursor:"pointer",fontSize:12,color:"#9ca3af",padding:"0 2px",lineHeight:1},children:"✕"})]}),r.jsx("div",{style:{pointerEvents:a?"none":"auto",zoom:E},children:r.jsx(i.Note,{mode:u.NoteMode.EDIT,context:I})}),r.jsx("div",{onPointerDown:s,style:{position:"absolute",bottom:0,right:0,width:14,height:14,cursor:"se-resize",background:"linear-gradient(135deg, transparent 50%, #9ca3af 50%)",borderRadius:"0 0 6px 0"}})]})}exports.CheckboxPlugin=i.CheckboxPlugin;exports.DEFAULT_BOOK=i.DEFAULT_BOOK;exports.DEFAULT_PAGE=i.DEFAULT_PAGE;exports.Note=i.Note;exports.NoteEdit=i.NoteEdit;exports.NoteForm=i.NoteForm;exports.NoteView=i.NoteView;exports.SelectPlugin=i.SelectPlugin;exports.TextPlugin=i.TextPlugin;exports.ValidationSeverity=i.ValidationSeverity;exports.addPage=i.addPage;exports.cleanValues=i.cleanValues;exports.createBlockId=i.createBlockId;exports.ensurePageIds=i.ensurePageIds;exports.gridSettingsWidget=i.gridSettingsWidget;exports.insertPage=i.insertPage;exports.movePage=i.movePage;exports.paperSettingsWidget=i.paperSettingsWidget;exports.removePage=i.removePage;exports.setPage=i.setPage;exports.validateBook=i.validateBook;exports.DEFAULT_GRID=u.DEFAULT_GRID;exports.DEFAULT_PAPER=u.DEFAULT_PAPER;exports.DEFAULT_PAPER_MARGIN=u.DEFAULT_PAPER_MARGIN;exports.DEFAULT_PAPER_SIZES=u.DEFAULT_PAPER_SIZES;exports.LineType=u.LineType;exports.NoteMode=u.NoteMode;exports.PaperSizePreset=u.PaperSizePreset;exports.deserializeBook=u.deserializeBook;exports.deserializePage=u.deserializePage;exports.deserializeValues=u.deserializeValues;exports.isBook=u.isBook;exports.isLegacyFormSchema=u.isLegacyFormSchema;exports.migrate=u.migrate;exports.migrateBook=u.migrateBook;exports.migrateFormSchemaToBook=u.migrateFormSchemaToBook;exports.migratePage=u.migratePage;exports.parseBook=u.parseBook;exports.serializeBook=u.serializeBook;exports.serializePage=u.serializePage;exports.ActionBar=U;exports.BASE_PLUGINS=te;exports.DefaultSelectionActionBarOverlay=K;exports.FloatingWidget=we;exports.Sidebar=X;exports.blockLayoutWidget=de;exports.canvasActionsWidget=re;exports.clipboardWidget=le;exports.createCanvasActionsWidget=V;exports.createClipboardWidget=H;exports.createHistoryWidget=W;exports.createPageNavigationWidget=$;exports.createPluginRegistry=O;exports.createSelectionDeleteWidget=F;exports.getDefaultActionBarSections=Pe;exports.getDefaultSidebarTabs=xe;exports.historyWidget=se;exports.pageNavigationWidget=ue;exports.printNote=Z;exports.selectionDeleteWidget=pe;exports.useNoteContext=ie;
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { C as ee, S as te, T as W, s as L, c as j, i as oe, r as ne, u as ae, a as ie, b as se, B as V, d as re, n as H, e as le, f as ce, g as de, h as ue, N as pe } from "./paperSettingsWidget-
|
|
2
|
-
import { D as Vt, j as Lt, k as Ht, l as Ot, m as Rt, V as Nt, o as $t, p as Ut, q as Wt, t as Ft, v as jt, w as Gt, x as qt } from "./paperSettingsWidget-
|
|
1
|
+
import { C as ee, S as te, T as W, s as L, c as j, i as oe, r as ne, u as ae, a as ie, b as se, B as V, d as re, n as H, e as le, f as ce, g as de, h as ue, N as pe } from "./paperSettingsWidget-d93s3Gsr.js";
|
|
2
|
+
import { D as Vt, j as Lt, k as Ht, l as Ot, m as Rt, V as Nt, o as $t, p as Ut, q as Wt, t as Ft, v as jt, w as Gt, x as qt } from "./paperSettingsWidget-d93s3Gsr.js";
|
|
3
3
|
import { useReducer as me, useRef as T, useCallback as I, useMemo as z, useState as q, isValidElement as ge, Fragment as ye, memo as Y, forwardRef as he, useEffect as ve, createElement as be } from "react";
|
|
4
|
-
import { P as A, u as ke, D as fe, N as Z, S as X } from "./sidebarPortal-
|
|
5
|
-
import { a as Zt, b as Xt, c as Kt, d as Jt, L as Qt, e as eo, f as to, g as oo, i as no, h as ao, m as io, j as so, k as ro, l as lo, p as co, s as uo, n as po } from "./sidebarPortal-
|
|
4
|
+
import { P as A, u as ke, D as fe, N as Z, S as X } from "./sidebarPortal-B2Mk9Aba.js";
|
|
5
|
+
import { a as Zt, b as Xt, c as Kt, d as Jt, L as Qt, e as eo, f as to, g as oo, i as no, h as ao, m as io, j as so, k as ro, l as lo, p as co, s as uo, n as po } from "./sidebarPortal-B2Mk9Aba.js";
|
|
6
6
|
import { flushSync as xe } from "react-dom";
|
|
7
7
|
import { createRoot as Pe } from "react-dom/client";
|
|
8
8
|
import { jsx as c, jsxs as M, Fragment as we } from "react/jsx-runtime";
|
|
9
|
-
import { s as U, A as Ce, I as O, C as Se, a as Be, b as Ie, D as Ee, c as ze, P as Ae, G as De, u as Te, S as Me, d as _e, g as Ve, e as Le, f as He, h as Oe, O as Re, T as Ne, i as $e, j as Ue, k as We } from "./PalettePanel-
|
|
9
|
+
import { s as U, A as Ce, I as O, C as Se, a as Be, b as Ie, D as Ee, c as ze, P as Ae, G as De, u as Te, S as Me, d as _e, g as Ve, e as Le, f as He, h as Oe, O as Re, T as Ne, i as $e, j as Ue, k as We } from "./PalettePanel-N5Y1TJAk.js";
|
|
10
10
|
import './index.css';function Fe(e) {
|
|
11
11
|
const t = {};
|
|
12
12
|
for (const o of e.properties)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";require('./paperSettingsWidget.css');const i=require("./sidebarPortal-Cr-dLvA_.cjs"),l=require("react"),h=require("react/jsx-runtime"),$e={kind:"fontStyle",defaultProps:{fontFamily:"sans-serif",fontSize:{value:16,unit:"px"},color:"#000000",fontWeight:!1,italic:!1,underline:!1,lineThrough:!1}},pe={kind:"padding",defaultProps:{top:{value:0,unit:"px"},right:{value:0,unit:"px"},bottom:{value:0,unit:"px"},left:{value:0,unit:"px"}}},Ge={kind:"placeholder",defaultProps:{placeholder:"テキストを入力"}},Ce={kind:"required",defaultProps:{required:!1}};var re=(e=>(e.ERROR="error",e.WARNING="warning",e.INFO="info",e))(re||{});function Xt(e){return!(e.length>200||/\((?:[^[\]()*+?\\]|\\.|\[[^\]]*\])[+*][^()]*\)[+*{]/.test(e))}function dt(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.required!==void 0||t.minLength!==void 0||t.maxLength!==void 0||t.pattern!==void 0}function ft(e,t){const n=[],r=t??"";if(e.required&&r.length===0&&n.push({code:"REQUIRED",message:"必須項目です",severity:re.ERROR}),e.minLength!==void 0&&r.length<e.minLength&&n.push({code:"MIN_LENGTH",message:`${e.minLength}文字以上入力してください`,severity:re.ERROR}),e.maxLength!==void 0&&r.length>e.maxLength&&n.push({code:"MAX_LENGTH",message:`${e.maxLength}文字以内で入力してください`,severity:re.ERROR}),e.pattern&&Xt(e.pattern))try{new RegExp(e.pattern).test(r)||n.push({code:"PATTERN",message:"形式が正しくありません",severity:re.ERROR})}catch{}return n}function Zt(e,t){return e.required&&t!==!0?[{code:"REQUIRED",message:"必須項目です",severity:re.ERROR}]:[]}function He(e){return`${e}_${crypto.randomUUID()}`}function he(e,t){if(e==null||t==null)return!1;if(typeof e=="string")return!!t.get(e);const n=t.get(e.path);return"eq"in e?n===e.eq:n!==e.neq}const Ve={grid:i.DEFAULT_GRID,blocks:[]},ht={paper:i.DEFAULT_PAPER,pages:[Ve]};function Yt(e){const t=i.Z_INDEX.BLOCK_LAYER_MIN+e*i.Z_INDEX.BLOCK_LAYER_STEP;return t>=i.Z_INDEX.BLOCK_LAYER_MAX?i.Z_INDEX.BLOCK_LAYER_MAX:t}function me(e,t){const n=Math.min(Math.max(0,t),i.Z_INDEX.BLOCK_LAYER_STEP-1);return e+n}function qt(){return Math.floor((i.Z_INDEX.BLOCK_LAYER_MAX-i.Z_INDEX.BLOCK_LAYER_MIN)/i.Z_INDEX.BLOCK_LAYER_STEP)}function Qt(e){const t=[],n=new Set,r=new Set,s=qt();for(const[c,d]of e.pages.entries()){for(const o of d.blocks)n.has(o.id)?r.add(o.id):n.add(o.id);d.blocks.length>s&&t.push({message:`ページ ${c+1} のブロック数 (${d.blocks.length}) が上限 (${s}) を超えています`,code:"BLOCK_COUNT_EXCEEDED",field:d.id??`page-${c}`,severity:re.ERROR})}for(const c of r)t.push({message:`blockId "${c}" が複数ページに重複して存在します`,code:"DUPLICATE_BLOCK_ID",field:c,severity:re.ERROR});return t}function le(e){if(e.length===0)throw new Error("pages must not be empty");return e}function Jt(e){const t={...Ve,id:crypto.randomUUID()};return{...e,pages:le([...e.pages,t])}}function en(e){const t=le(e.pages.map(n=>n.id!==void 0?n:{...n,id:crypto.randomUUID()}));return{...e,pages:t}}function tn(e,t){if(e.pages.length<=1)return e;const n=e.pages.filter((r,s)=>s!==t);return{...e,pages:le(n)}}function nn(e,t,n){if(t===n)return e;const r=[...e.pages],s=r.splice(t,1)[0];return s?(r.splice(n,0,s),{...e,pages:le(r)}):e}function gt(e,t,n){return{...e,pages:le(e.pages.map((r,s)=>s===t?n:r))}}function rn(e,t,n){const r=[...e.pages.slice(0,t+1),n,...e.pages.slice(t+1)];return{...e,pages:le(r)}}function on(e,t){const n=new Set(e.pages.flatMap(r=>r.blocks.map(s=>s.id)));return Object.fromEntries(Object.entries(t).filter(([r])=>n.has(r)))}function sn(e,t){const n=i.DEFAULT_PAPER_SIZES[e],r=i.toMm.fromDim(n.width),s=i.toMm.fromDim(n.height);return t?{width:s,height:r}:{width:r,height:s}}function ln(e,t){return{...e.paper,size:(t==null?void 0:t.paperSize)!=null?i.DEFAULT_PAPER_SIZES[t.paperSize]??e.paper.size:e.paper.size,orientation:(t==null?void 0:t.orientation)??e.paper.orientation}}function an(e,t){const n=e.orientation===!0,r=Math.round(i.toMm.fromDim(n?e.size.height:e.size.width)),s=Math.round(i.toMm.fromDim(n?e.size.width:e.size.height)),c=t?`margin-top:${t.top??"0"};margin-right:${t.right??"0"};margin-bottom:${t.bottom??"0"};margin-left:${t.left??"0"};`:"margin:0;";return`@page { size: ${r}mm ${s}mm; ${c} }`}const cn={[i.HorizontalAlign.left]:"flex-start",[i.HorizontalAlign.center]:"center",[i.HorizontalAlign.right]:"flex-end"},un={[i.VerticalAlign.top]:"flex-start",[i.VerticalAlign.center]:"center",[i.VerticalAlign.bottom]:"flex-end"},We=l.forwardRef(({id:e,props:t,value:n,onChange:r,readOnly:s,ariaLabel:c},d)=>{var y;const o=l.useRef(null);l.useImperativeHandle(d,()=>({focus:()=>{var w;return(w=o.current)==null?void 0:w.focus()}}),[]);const f=n??!1,g=l.useMemo(()=>{const w={width:"100%",height:"100%",display:"flex",boxSizing:"border-box",overflow:"hidden",cursor:s?"default":"pointer"};w.justifyContent=cn[t.horizontal??i.HorizontalAlign.center],w.alignItems=un[t.vertical??i.VerticalAlign.center];const b=t.bulk?t.all:void 0,x=b??t.top,R=b??t.right,m=b??t.bottom,v=b??t.left;return x&&(w.paddingTop=i.dimensionToString(x)),R&&(w.paddingRight=i.dimensionToString(R)),m&&(w.paddingBottom=i.dimensionToString(m)),v&&(w.paddingLeft=i.dimensionToString(v)),w},[t,s]),a=(y=t.styleConfig)!=null&&y.checkboxSize?i.toPx.fromDim(t.styleConfig.checkboxSize):16,u=()=>{s||r(!f)};return h.jsxs("div",{ref:o,style:g,role:"switch","aria-checked":f,"aria-label":c,tabIndex:s?-1:0,onClick:u,onKeyDown:w=>{(w.key===" "||w.key==="Enter")&&(w.preventDefault(),u())},children:[h.jsx("input",{id:e,type:"checkbox",checked:f,onChange:()=>{},style:{display:"none"},tabIndex:-1,readOnly:!0}),h.jsx("div",{style:{width:a,height:a,flexShrink:0,pointerEvents:"none"},children:h.jsx(i.ClassicCheckboxVisual,{checked:f,styleConfig:t.styleConfig})})]})});We.displayName="CheckboxRenderer";const dn={...i.alignmentProp,defaultProps:{...i.alignmentProp.defaultProps,horizontal:i.HorizontalAlign.center}},Ke={kind:"checkbox",meta:{displayName:"チェックボックス",description:"チェック/非チェックを選択する入力ブロック",defaultSize:{w:2,h:2}},Renderer:We,properties:[dn,pe,Ce,i.checkboxStyleProp],validateProps:e=>({...typeof e=="object"&&e!==null?e:{}}),validateValue:e=>typeof e=="boolean"?e:!1},pt={kind:"selectConfig",defaultProps:{selectConfig:{options:[{label:"option1",value:"option1"},{label:"option2",value:"option2"}]}}};function rt(e){return/^#[0-9a-fA-F]{3,8}$/.test(e)}const fn={[i.HorizontalAlign.left]:"left",[i.HorizontalAlign.center]:"center",[i.HorizontalAlign.right]:"right"},hn={[i.VerticalAlign.top]:"flex-start",[i.VerticalAlign.center]:"center",[i.VerticalAlign.bottom]:"flex-end"},Fe=l.forwardRef(({id:e,props:t,value:n,onChange:r,readOnly:s,mode:c,ariaLabel:d},o)=>{var O,S,L;const f=l.useRef(null);l.useImperativeHandle(o,()=>({focus:()=>{var N;return(N=f.current)==null?void 0:N.focus()}}),[]);const g=s||c===i.NoteMode.VIEW,a=l.useMemo(()=>{const N={width:"100%",height:"100%",position:"relative",display:"flex",alignItems:hn[t.vertical??i.VerticalAlign.center],boxSizing:"border-box",overflow:"hidden"},I=t.bulk?t.all:void 0,M=I??t.top,C=I??t.right,H=I??t.bottom,q=I??t.left;return M&&(N.paddingTop=i.dimensionToString(M)),C&&(N.paddingRight=i.dimensionToString(C)),H&&(N.paddingBottom=i.dimensionToString(H)),q&&(N.paddingLeft=i.dimensionToString(q)),N},[t]),u=(((O=t.selectConfig)==null?void 0:O.options)??[]).find(N=>N.value===n),y=u==null?void 0:u.color,w=y&&rt(y)?y:void 0,b=l.useMemo(()=>{const N={appearance:"none",WebkitAppearance:"none",background:w??"transparent",border:"none",outline:"none",width:"100%",height:"auto",padding:"0 20px 0 4px",boxSizing:"border-box",cursor:g?"default":"pointer",textAlign:fn[t.horizontal??i.HorizontalAlign.left]};t.fontFamily&&(N.fontFamily=t.fontFamily),t.fontSize&&(N.fontSize=`${i.toPx.fromDim(t.fontSize)}px`),t.color&&(N.color=t.color),N.fontWeight=t.fontWeight?"bold":"normal",N.fontStyle=t.italic?"italic":"normal";const I=[];return t.underline&&I.push("underline"),t.lineThrough&&I.push("line-through"),I.length>0&&(N.textDecoration=I.join(" ")),N},[t,w,g]),x={position:"absolute",right:6,top:"50%",transform:"translateY(-50%)",width:0,height:0,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:`5px solid ${g?"#aaa":"#555"}`,pointerEvents:"none"},R=N=>{const I=N.target.value===""?null:N.target.value;r(I)},m=N=>{var I,M;!g&&N.target!==f.current&&((M=(I=f.current)==null?void 0:I.showPicker)==null||M.call(I))},v=N=>{var I,M;!g&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),(M=(I=f.current)==null?void 0:I.showPicker)==null||M.call(I))};if(c===i.NoteMode.VIEW){const N=(u==null?void 0:u.label)??(n!=null?String(n):t.placeholder??""),I={...b,height:"auto",padding:"0 4px"};return h.jsx("div",{style:a,children:h.jsx("div",{style:I,children:N})})}const P=h.jsxs(h.Fragment,{children:[h.jsxs("select",{ref:f,id:e,value:n??"",onChange:R,disabled:g,style:b,"aria-label":d,children:[t.placeholder!==void 0&&!t.required&&((S=t.selectConfig)==null?void 0:S.allowEmpty)!==!1&&h.jsx("option",{value:"",children:t.placeholder}),(((L=t.selectConfig)==null?void 0:L.options)??[]).map(N=>{const I=N.color&&rt(N.color)?N.color:void 0;return h.jsx("option",{value:N.value,style:I?{backgroundColor:I}:void 0,children:N.label},N.value)})]}),h.jsx("div",{style:x,"aria-hidden":"true"})]});return g?h.jsx("div",{style:a,children:P}):h.jsx("div",{style:a,role:"none",onClick:m,onKeyDown:v,children:P})});Fe.displayName="SelectRenderer";const Pe={kind:"select",meta:{displayName:"セレクトボックス",description:"ドロップダウンから選択肢を選ぶ入力ブロック",defaultSize:{w:4,h:2}},Renderer:Fe,properties:[i.alignmentProp,pe,$e,Ge,Ce,pt],validateProps:e=>{if(typeof e!="object"||e===null)return{};const t=e,n=t.selectConfig;if(typeof n=="object"&&n!==null&&Array.isArray(n.options)&&n.options.every(d=>typeof d=="object"&&d!==null&&typeof d.label=="string"&&typeof d.value=="string"))return{...t,selectConfig:n};const{selectConfig:s,...c}=t;return{...c,selectConfig:{options:[]}}},validateValue:e=>typeof e=="string"?e:null},gn={[i.HorizontalAlign.left]:"flex-start",[i.HorizontalAlign.center]:"center",[i.HorizontalAlign.right]:"flex-end"},pn={[i.VerticalAlign.top]:"flex-start",[i.VerticalAlign.center]:"center",[i.VerticalAlign.bottom]:"flex-end"},Ue=l.forwardRef(({props:e,value:t,onChange:n,onBlur:r,readOnly:s,mode:c,onMeasureHeight:d,onMeasureWidth:o,ariaLabel:f},g)=>{const a=l.useRef(null),u=l.useRef(null),y=l.useRef(null),w=l.useRef(null),[b,x]=l.useState(null),R=l.useRef(null),m=l.useRef(null),v=t!=null?String(t):"";l.useLayoutEffect(()=>{if(!e.multiline)return;const E=y.current,T=u.current;if(!E||!T)return;const F=v+(v.endsWith(`
|
|
1
|
+
"use strict";require('./paperSettingsWidget.css');const i=require("./sidebarPortal-BCIVv4yO.cjs"),l=require("react"),h=require("react/jsx-runtime"),$e={kind:"fontStyle",defaultProps:{fontFamily:"sans-serif",fontSize:{value:16,unit:"px"},color:"#000000",fontWeight:!1,italic:!1,underline:!1,lineThrough:!1}},pe={kind:"padding",defaultProps:{top:{value:0,unit:"px"},right:{value:0,unit:"px"},bottom:{value:0,unit:"px"},left:{value:0,unit:"px"}}},Ge={kind:"placeholder",defaultProps:{placeholder:"テキストを入力"}},Ce={kind:"required",defaultProps:{required:!1}};var re=(e=>(e.ERROR="error",e.WARNING="warning",e.INFO="info",e))(re||{});function Xt(e){return!(e.length>200||/\((?:[^[\]()*+?\\]|\\.|\[[^\]]*\])[+*][^()]*\)[+*{]/.test(e))}function dt(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.required!==void 0||t.minLength!==void 0||t.maxLength!==void 0||t.pattern!==void 0}function ft(e,t){const n=[],r=t??"";if(e.required&&r.length===0&&n.push({code:"REQUIRED",message:"必須項目です",severity:re.ERROR}),e.minLength!==void 0&&r.length<e.minLength&&n.push({code:"MIN_LENGTH",message:`${e.minLength}文字以上入力してください`,severity:re.ERROR}),e.maxLength!==void 0&&r.length>e.maxLength&&n.push({code:"MAX_LENGTH",message:`${e.maxLength}文字以内で入力してください`,severity:re.ERROR}),e.pattern&&Xt(e.pattern))try{new RegExp(e.pattern).test(r)||n.push({code:"PATTERN",message:"形式が正しくありません",severity:re.ERROR})}catch{}return n}function Zt(e,t){return e.required&&t!==!0?[{code:"REQUIRED",message:"必須項目です",severity:re.ERROR}]:[]}function He(e){return`${e}_${crypto.randomUUID()}`}function he(e,t){if(e==null||t==null)return!1;if(typeof e=="string")return!!t.get(e);const n=t.get(e.path);return"eq"in e?n===e.eq:n!==e.neq}const Ve={grid:i.DEFAULT_GRID,blocks:[]},ht={paper:i.DEFAULT_PAPER,pages:[Ve]};function Yt(e){const t=i.Z_INDEX.BLOCK_LAYER_MIN+e*i.Z_INDEX.BLOCK_LAYER_STEP;return t>=i.Z_INDEX.BLOCK_LAYER_MAX?i.Z_INDEX.BLOCK_LAYER_MAX:t}function me(e,t){const n=Math.min(Math.max(0,t),i.Z_INDEX.BLOCK_LAYER_STEP-1);return e+n}function qt(){return Math.floor((i.Z_INDEX.BLOCK_LAYER_MAX-i.Z_INDEX.BLOCK_LAYER_MIN)/i.Z_INDEX.BLOCK_LAYER_STEP)}function Qt(e){const t=[],n=new Set,r=new Set,s=qt();for(const[c,d]of e.pages.entries()){for(const o of d.blocks)n.has(o.id)?r.add(o.id):n.add(o.id);d.blocks.length>s&&t.push({message:`ページ ${c+1} のブロック数 (${d.blocks.length}) が上限 (${s}) を超えています`,code:"BLOCK_COUNT_EXCEEDED",field:d.id??`page-${c}`,severity:re.ERROR})}for(const c of r)t.push({message:`blockId "${c}" が複数ページに重複して存在します`,code:"DUPLICATE_BLOCK_ID",field:c,severity:re.ERROR});return t}function le(e){if(e.length===0)throw new Error("pages must not be empty");return e}function Jt(e){const t={...Ve,id:crypto.randomUUID()};return{...e,pages:le([...e.pages,t])}}function en(e){const t=le(e.pages.map(n=>n.id!==void 0?n:{...n,id:crypto.randomUUID()}));return{...e,pages:t}}function tn(e,t){if(e.pages.length<=1)return e;const n=e.pages.filter((r,s)=>s!==t);return{...e,pages:le(n)}}function nn(e,t,n){if(t===n)return e;const r=[...e.pages],s=r.splice(t,1)[0];return s?(r.splice(n,0,s),{...e,pages:le(r)}):e}function gt(e,t,n){return{...e,pages:le(e.pages.map((r,s)=>s===t?n:r))}}function rn(e,t,n){const r=[...e.pages.slice(0,t+1),n,...e.pages.slice(t+1)];return{...e,pages:le(r)}}function on(e,t){const n=new Set(e.pages.flatMap(r=>r.blocks.map(s=>s.id)));return Object.fromEntries(Object.entries(t).filter(([r])=>n.has(r)))}function sn(e,t){const n=i.DEFAULT_PAPER_SIZES[e],r=i.toMm.fromDim(n.width),s=i.toMm.fromDim(n.height);return t?{width:s,height:r}:{width:r,height:s}}function ln(e,t){return{...e.paper,size:(t==null?void 0:t.paperSize)!=null?i.DEFAULT_PAPER_SIZES[t.paperSize]??e.paper.size:e.paper.size,orientation:(t==null?void 0:t.orientation)??e.paper.orientation}}function an(e,t){const n=e.orientation===!0,r=Math.round(i.toMm.fromDim(n?e.size.height:e.size.width)),s=Math.round(i.toMm.fromDim(n?e.size.width:e.size.height)),c=t?`margin-top:${t.top??"0"};margin-right:${t.right??"0"};margin-bottom:${t.bottom??"0"};margin-left:${t.left??"0"};`:"margin:0;";return`@page { size: ${r}mm ${s}mm; ${c} }`}const cn={[i.HorizontalAlign.left]:"flex-start",[i.HorizontalAlign.center]:"center",[i.HorizontalAlign.right]:"flex-end"},un={[i.VerticalAlign.top]:"flex-start",[i.VerticalAlign.center]:"center",[i.VerticalAlign.bottom]:"flex-end"},We=l.forwardRef(({id:e,props:t,value:n,onChange:r,readOnly:s,ariaLabel:c},d)=>{var y;const o=l.useRef(null);l.useImperativeHandle(d,()=>({focus:()=>{var w;return(w=o.current)==null?void 0:w.focus()}}),[]);const f=n??!1,g=l.useMemo(()=>{const w={width:"100%",height:"100%",display:"flex",boxSizing:"border-box",overflow:"hidden",cursor:s?"default":"pointer"};w.justifyContent=cn[t.horizontal??i.HorizontalAlign.center],w.alignItems=un[t.vertical??i.VerticalAlign.center];const b=t.bulk?t.all:void 0,x=b??t.top,R=b??t.right,m=b??t.bottom,v=b??t.left;return x&&(w.paddingTop=i.dimensionToString(x)),R&&(w.paddingRight=i.dimensionToString(R)),m&&(w.paddingBottom=i.dimensionToString(m)),v&&(w.paddingLeft=i.dimensionToString(v)),w},[t,s]),a=(y=t.styleConfig)!=null&&y.checkboxSize?i.toPx.fromDim(t.styleConfig.checkboxSize):16,u=()=>{s||r(!f)};return h.jsxs("div",{ref:o,style:g,role:"switch","aria-checked":f,"aria-label":c,tabIndex:s?-1:0,onClick:u,onKeyDown:w=>{(w.key===" "||w.key==="Enter")&&(w.preventDefault(),u())},children:[h.jsx("input",{id:e,type:"checkbox",checked:f,onChange:()=>{},style:{display:"none"},tabIndex:-1,readOnly:!0}),h.jsx("div",{style:{width:a,height:a,flexShrink:0,pointerEvents:"none"},children:h.jsx(i.ClassicCheckboxVisual,{checked:f,styleConfig:t.styleConfig})})]})});We.displayName="CheckboxRenderer";const dn={...i.alignmentProp,defaultProps:{...i.alignmentProp.defaultProps,horizontal:i.HorizontalAlign.center}},Ke={kind:"checkbox",meta:{displayName:"チェックボックス",description:"チェック/非チェックを選択する入力ブロック",defaultSize:{w:2,h:2}},Renderer:We,properties:[dn,pe,Ce,i.checkboxStyleProp],validateProps:e=>({...typeof e=="object"&&e!==null?e:{}}),validateValue:e=>typeof e=="boolean"?e:!1},pt={kind:"selectConfig",defaultProps:{selectConfig:{options:[{label:"option1",value:"option1"},{label:"option2",value:"option2"}]}}};function rt(e){return/^#[0-9a-fA-F]{3,8}$/.test(e)}const fn={[i.HorizontalAlign.left]:"left",[i.HorizontalAlign.center]:"center",[i.HorizontalAlign.right]:"right"},hn={[i.VerticalAlign.top]:"flex-start",[i.VerticalAlign.center]:"center",[i.VerticalAlign.bottom]:"flex-end"},Fe=l.forwardRef(({id:e,props:t,value:n,onChange:r,readOnly:s,mode:c,ariaLabel:d},o)=>{var O,S,L;const f=l.useRef(null);l.useImperativeHandle(o,()=>({focus:()=>{var N;return(N=f.current)==null?void 0:N.focus()}}),[]);const g=s||c===i.NoteMode.VIEW,a=l.useMemo(()=>{const N={width:"100%",height:"100%",position:"relative",display:"flex",alignItems:hn[t.vertical??i.VerticalAlign.center],boxSizing:"border-box",overflow:"hidden"},I=t.bulk?t.all:void 0,M=I??t.top,C=I??t.right,H=I??t.bottom,q=I??t.left;return M&&(N.paddingTop=i.dimensionToString(M)),C&&(N.paddingRight=i.dimensionToString(C)),H&&(N.paddingBottom=i.dimensionToString(H)),q&&(N.paddingLeft=i.dimensionToString(q)),N},[t]),u=(((O=t.selectConfig)==null?void 0:O.options)??[]).find(N=>N.value===n),y=u==null?void 0:u.color,w=y&&rt(y)?y:void 0,b=l.useMemo(()=>{const N={appearance:"none",WebkitAppearance:"none",background:w??"transparent",border:"none",outline:"none",width:"100%",height:"auto",padding:"0 20px 0 4px",boxSizing:"border-box",cursor:g?"default":"pointer",textAlign:fn[t.horizontal??i.HorizontalAlign.left]};t.fontFamily&&(N.fontFamily=t.fontFamily),t.fontSize&&(N.fontSize=`${i.toPx.fromDim(t.fontSize)}px`),t.color&&(N.color=t.color),N.fontWeight=t.fontWeight?"bold":"normal",N.fontStyle=t.italic?"italic":"normal";const I=[];return t.underline&&I.push("underline"),t.lineThrough&&I.push("line-through"),I.length>0&&(N.textDecoration=I.join(" ")),N},[t,w,g]),x={position:"absolute",right:6,top:"50%",transform:"translateY(-50%)",width:0,height:0,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:`5px solid ${g?"#aaa":"#555"}`,pointerEvents:"none"},R=N=>{const I=N.target.value===""?null:N.target.value;r(I)},m=N=>{var I,M;!g&&N.target!==f.current&&((M=(I=f.current)==null?void 0:I.showPicker)==null||M.call(I))},v=N=>{var I,M;!g&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),(M=(I=f.current)==null?void 0:I.showPicker)==null||M.call(I))};if(c===i.NoteMode.VIEW){const N=(u==null?void 0:u.label)??(n!=null?String(n):t.placeholder??""),I={...b,height:"auto",padding:"0 4px"};return h.jsx("div",{style:a,children:h.jsx("div",{style:I,children:N})})}const P=h.jsxs(h.Fragment,{children:[h.jsxs("select",{ref:f,id:e,value:n??"",onChange:R,disabled:g,style:b,"aria-label":d,children:[t.placeholder!==void 0&&!t.required&&((S=t.selectConfig)==null?void 0:S.allowEmpty)!==!1&&h.jsx("option",{value:"",children:t.placeholder}),(((L=t.selectConfig)==null?void 0:L.options)??[]).map(N=>{const I=N.color&&rt(N.color)?N.color:void 0;return h.jsx("option",{value:N.value,style:I?{backgroundColor:I}:void 0,children:N.label},N.value)})]}),h.jsx("div",{style:x,"aria-hidden":"true"})]});return g?h.jsx("div",{style:a,children:P}):h.jsx("div",{style:a,role:"none",onClick:m,onKeyDown:v,children:P})});Fe.displayName="SelectRenderer";const Pe={kind:"select",meta:{displayName:"セレクトボックス",description:"ドロップダウンから選択肢を選ぶ入力ブロック",defaultSize:{w:4,h:2}},Renderer:Fe,properties:[i.alignmentProp,pe,$e,Ge,Ce,pt],validateProps:e=>{if(typeof e!="object"||e===null)return{};const t=e,n=t.selectConfig;if(typeof n=="object"&&n!==null&&Array.isArray(n.options)&&n.options.every(d=>typeof d=="object"&&d!==null&&typeof d.label=="string"&&typeof d.value=="string"))return{...t,selectConfig:n};const{selectConfig:s,...c}=t;return{...c,selectConfig:{options:[]}}},validateValue:e=>typeof e=="string"?e:null},gn={[i.HorizontalAlign.left]:"flex-start",[i.HorizontalAlign.center]:"center",[i.HorizontalAlign.right]:"flex-end"},pn={[i.VerticalAlign.top]:"flex-start",[i.VerticalAlign.center]:"center",[i.VerticalAlign.bottom]:"flex-end"},Ue=l.forwardRef(({props:e,value:t,onChange:n,onBlur:r,readOnly:s,mode:c,onMeasureHeight:d,onMeasureWidth:o,ariaLabel:f},g)=>{const a=l.useRef(null),u=l.useRef(null),y=l.useRef(null),w=l.useRef(null),[b,x]=l.useState(null),R=l.useRef(null),m=l.useRef(null),v=t!=null?String(t):"";l.useLayoutEffect(()=>{if(!e.multiline)return;const E=y.current,T=u.current;if(!E||!T)return;const F=v+(v.endsWith(`
|
|
2
2
|
`)?" ":"");E.textContent=F||" ";const p=window.getComputedStyle(T),_=Number.parseFloat(p.paddingTop),$=Number.parseFloat(p.paddingBottom),z=Number.parseFloat(p.paddingLeft),j=Number.parseFloat(p.paddingRight),k=T.clientWidth-z-j;E.style.width=`${k}px`,E.style.paddingTop="0px",E.style.paddingBottom="0px";const D=E.scrollHeight;if(x(D),d){const B=D+_+$;B!==R.current&&(R.current=B,d(B))}},[e,v,d]),l.useLayoutEffect(()=>{if(!o)return;const E=w.current;if(!E)return;E.textContent=v;const T=E.offsetWidth+2;T!==m.current&&(m.current=T,o(T))},[v,o]),l.useImperativeHandle(g,()=>({focus:()=>{var E;return(E=a.current)==null?void 0:E.focus()}}),[]);const P=!s,O=l.useMemo(()=>{const E={position:"relative",width:"100%",height:"100%",display:"flex",boxSizing:"border-box",overflow:"hidden",cursor:P?"text":"default"};E.justifyContent=gn[e.horizontal??i.HorizontalAlign.left],E.alignItems=pn[e.vertical??i.VerticalAlign.center];const T=e.bulk?e.all:void 0,F=T??e.top,p=T??e.right,_=T??e.bottom,$=T??e.left;return F&&(E.paddingTop=i.dimensionToString(F)),p&&(E.paddingRight=i.dimensionToString(p)),_&&(E.paddingBottom=i.dimensionToString(_)),$&&(E.paddingLeft=i.dimensionToString($)),E},[e,P]),S=l.useMemo(()=>{const E={background:"transparent",border:"none",outline:"none",resize:"none",padding:0,margin:0,width:"100%",whiteSpace:o?e.multiline?"pre":"nowrap":void 0,boxSizing:"border-box",fontFamily:"inherit",color:"inherit"};e.fontSize&&(E.fontSize=`${i.toPx.fromDim(e.fontSize)}px`),e.fontFamily&&(E.fontFamily=e.fontFamily),e.color&&(E.color=e.color),E.fontWeight=e.fontWeight?"bold":"normal",E.fontStyle=e.italic?"italic":"normal";const T=[];switch(e.underline&&T.push("underline"),e.lineThrough&&T.push("line-through"),E.textDecoration=T.length>0?T.join(" "):"none",e.lineHeight&&(E.lineHeight=e.lineHeight),e.horizontal){case i.HorizontalAlign.center:E.textAlign="center";break;case i.HorizontalAlign.right:E.textAlign="right";break;default:E.textAlign="left"}return E},[e,o]),L=l.useMemo(()=>({...S,position:"absolute",top:0,left:0,visibility:"hidden",pointerEvents:"none",whiteSpace:"pre",width:"auto",height:"auto",overflow:"visible"}),[S]),N=l.useMemo(()=>{const E=!!o;return{...S,position:"absolute",top:0,left:0,width:"100%",height:"auto",visibility:"hidden",pointerEvents:"none",overflow:"hidden",whiteSpace:E?"pre":"pre-wrap",wordWrap:E?"normal":"break-word",overflowWrap:E?"normal":"break-word",padding:0,border:"none",boxSizing:"border-box"}},[S,o]),I=E=>{n(E.target.value)},M=()=>{r==null||r(t)},C=l.useMemo(()=>{if(!e.pattern)return null;const E=e.pattern.match(/^(\[.+?\])\+$/);if(!E)return null;try{return new RegExp(`^${E[1]}$`)}catch{return null}},[e.pattern]),H=l.useMemo(()=>e.inputType==="number"?"numeric":e.inputType==="tel"?"tel":e.inputType==="email"?"email":e.inputType==="url"?"url":e.pattern==="[0-9]+"?"numeric":"text",[e.inputType,e.pattern]),q=l.useCallback(E=>{if(!C)return;const T=E.nativeEvent;if(T.data){for(const F of T.data)if(!C.test(F)){E.preventDefault();return}}},[C]),J=l.useCallback(E=>{if(!C)return;const T=E.currentTarget,F=[...T.value].filter(p=>C.test(p)).join("");F!==T.value&&n(F)},[C,n]),W=c===i.NoteMode.EDIT||c===i.NoteMode.FORM?e.placeholder:void 0,A=E=>{var T;P&&E.target===E.currentTarget&&((T=a.current)==null||T.focus())};if(e.multiline){const E={...S,resize:"none",overflow:o||c===i.NoteMode.VIEW?"hidden":"auto",height:b!==null?`${b}px`:"auto"},T=F=>{a.current=F};return h.jsxs("div",{ref:u,style:O,role:"none",onClick:A,onKeyDown:F=>{var p;P&&(F.key==="Enter"||F.key===" ")&&((p=a.current)==null||p.focus())},children:[h.jsx("div",{ref:y,style:N,"aria-hidden":"true"}),h.jsx("textarea",{ref:T,value:v,onChange:I,onBlur:M,onBeforeInput:q,onCompositionEnd:J,inputMode:H,style:E,placeholder:W,readOnly:!P,tabIndex:P?0:-1,"aria-label":f}),o&&h.jsx("span",{ref:w,"aria-hidden":"true",style:L})]})}return h.jsxs("div",{style:O,role:"none",onClick:A,onKeyDown:E=>{var T;P&&(E.key==="Enter"||E.key===" ")&&((T=a.current)==null||T.focus())},children:[h.jsx("input",{ref:a,type:e.inputType??"text",value:v,onChange:I,onBlur:M,onBeforeInput:q,onCompositionEnd:J,inputMode:H,style:S,placeholder:W,readOnly:!P,tabIndex:P?0:-1,"aria-label":f,min:e.min,max:e.max,step:e.step}),o&&h.jsx("span",{ref:w,"aria-hidden":"true",style:L})]})});Ue.displayName="TextRenderer";const ae={kind:"text",meta:{displayName:"テキスト",description:"テキスト入力用ブロック",defaultSize:{w:3,h:1}},Renderer:Ue,properties:[i.alignmentProp,pe,$e,Ge,Ce,i.textBehaviorProp,i.textValidationProp],validateProps:e=>{const n={...typeof e=="object"&&e!==null?e:{}};typeof n.minLength!="number"&&(n.minLength=void 0),typeof n.maxLength!="number"&&(n.maxLength=void 0),typeof n.pattern!="string"&&(n.pattern=void 0),["text","number","email","tel","url","date","password"].includes(n.inputType)||(n.inputType=void 0);for(const s of["min","max","step"])s in n&&typeof n[s]!="number"&&(n[s]=void 0);return n},validateValue:e=>{if(typeof e=="string")return e;if(typeof e=="number")return String(e)}};function mn(e){const t=l.useRef(e);t.current=e;const n=l.useCallback((s,c)=>{const d=t.current[s];d&&(c!==void 0&&d.validatePayload!==void 0&&!d.validatePayload(c)||d.execute(c))},[]),r=l.useCallback(s=>{var c;return((c=t.current[s])==null?void 0:c.isEnabled())??!1},[]);return l.useMemo(()=>({execute:n,isEnabled:r}),[n,r])}function Re(e,t,n){if(t.length===0)return n;const[r,...s]=t,c=typeof e=="object"&&e!==null?e:{};return{...c,[r]:Re(c[r],s,n)}}function yn(e,t,n){const r=t.split(".");return Re(e,r,n)}function Be(e,t){const n=t.split(".");let r=e;for(const s of n){if(r===null||typeof r!="object")return null;r=r[s]}return r??null}function xn(e,t,n){const r=l.useRef(e);r.current=e;const s=l.useRef((n==null?void 0:n.pageIdx)??0);s.current=(n==null?void 0:n.pageIdx)??0;const c=l.useRef(n==null?void 0:n.extra);c.current=n==null?void 0:n.extra;const d=l.useCallback(f=>{var u;const g=c.current;if(g){const y=g.get(f);if(y!==void 0)return y}const a=r.current;return f.startsWith("margin.")?Be(a.paper.margin,f.slice(7)):f.startsWith("grid.")?Be((u=a.pages[s.current])==null?void 0:u.grid,f.slice(5)):Be(a,f)},[]),o=l.useCallback((f,g)=>{var y;const a=c.current;if(a&&a.get(f)!==void 0){a.set(f,g);return}const u=r.current;if(f.startsWith("margin.")){if(f==="margin.bulk"&&g===!0){const x=u.paper.margin,R=(y=x.all)!=null&&y.unit?x.all:x.top;t({...u,paper:{...u.paper,margin:{...x,bulk:!0,all:R}}},{mergeKey:i.bindingKey(f)});return}const w=f.slice(7),b=Re(u.paper.margin,w.split("."),g);t({...u,paper:{...u.paper,margin:b}},{mergeKey:i.bindingKey(f)});return}if(f.startsWith("grid.")){const w=s.current,b=u.pages[w];if(!b)return;const x=Re(b.grid,f.slice(5).split("."),g),R=u.pages.map((m,v)=>v===w?{...m,grid:x}:m);t({...u,pages:R},{mergeKey:i.bindingKey(f)});return}t(yn(u,f,g),{mergeKey:i.bindingKey(f)})},[t]);return l.useMemo(()=>({get:d,set:o}),[d,o])}const vn=500;function wn(e,t){switch(t.type){case"push":{const n=e.entries[e.idx];if(t.mergeKey!==void 0&&(n==null?void 0:n.mergeKey)===t.mergeKey&&(t.noTimeWindow===!0||t.timestamp-((n==null?void 0:n.timestamp)??0)<vn))return{entries:[...e.entries.slice(0,e.idx),{book:t.book,mergeKey:t.mergeKey,timestamp:t.timestamp}],idx:e.idx};const s=[...e.entries.slice(0,e.idx+1),{book:t.book,mergeKey:t.mergeKey,timestamp:t.timestamp}],c=s.length>t.maxHistory?s.slice(s.length-t.maxHistory):s;return{entries:c,idx:c.length-1}}case"undo":return{...e,idx:Math.max(0,e.idx-1)};case"redo":return{...e,idx:Math.min(e.entries.length-1,e.idx+1)}}}const ot=100;function bn({initialBook:e,maxHistory:t=ot}){var g;const n=t??ot,[r,s]=l.useReducer(wn,void 0,()=>({entries:[{book:e,timestamp:Date.now()}],idx:0})),c=((g=r.entries[r.idx])==null?void 0:g.book)??e,d=l.useCallback((a,u)=>{s({type:"push",book:a,mergeKey:u==null?void 0:u.mergeKey,noTimeWindow:u==null?void 0:u.noTimeWindow,timestamp:Date.now(),maxHistory:n})},[n]),o=l.useCallback(()=>s({type:"undo"}),[]),f=l.useCallback(()=>s({type:"redo"}),[]);return{book:c,handleBookChange:d,canUndo:r.idx>0,canRedo:r.idx<r.entries.length-1,undo:o,redo:f,historyActionHandlers:{undo:{execute:o,isEnabled:()=>r.idx>0},redo:{execute:f,isEnabled:()=>r.idx<r.entries.length-1}}}}function En(e,t){if(e===i.LineType.DASHED)return`${t*4} ${t*2}`;if(e===i.LineType.DOTTED)return`${t*1} ${t*2}`}function we(e,t){return{stroke:e.color,strokeWidth:i.toPx.fromDim(e.width,t),strokeDasharray:En(e.type,e.width.value)}}const ce=l.memo(({blockSizePx:e,borderStyle:t,blockZIndex:n,subZIndex:r=i.BLOCK_SUB_INDEX.BORDER,visible:s=!0,dpi:c=i.DEFAULT_DPI})=>{if(!s||!t)return null;const{top:d,right:o,bottom:f,left:g}=t;if(!d&&!o&&!f&&!g)return null;const{width:a,height:u}=e,y=me(n,r);return h.jsxs("svg",{role:"presentation","aria-hidden":"true",style:{position:"absolute",inset:0,width:`${a}px`,height:`${u}px`,pointerEvents:"none",overflow:"visible",zIndex:y},width:a,height:u,"data-testid":"block-border",children:[d&&h.jsx("line",{x1:0,y1:0,x2:a,y2:0,...we(d,c)}),o&&h.jsx("line",{x1:a,y1:0,x2:a,y2:u,...we(o,c)}),f&&h.jsx("line",{x1:0,y1:u,x2:a,y2:u,...we(f,c)}),g&&h.jsx("line",{x1:0,y1:0,x2:0,y2:u,...we(g,c)})]})});ce.displayName="BlockBorder";const ye=l.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=i.BLOCK_SUB_INDEX.BG,backgroundColor:r="transparent"})=>{const s=me(t,n),c={position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:r,pointerEvents:"none",zIndex:s};return h.jsx("div",{style:c,role:"presentation","aria-hidden":"true","data-testid":"block-canvas"})});ye.displayName="BlockCanvas";function be(e,t){if(e===i.LineType.DASHED)return`${t*3} ${t*2}`;if(e===i.LineType.DOTTED)return`${t} ${t*2}`}const Ne={top:{color:"#cccccc",width:{value:1,unit:"px"},type:i.LineType.SOLID},right:{color:"#cccccc",width:{value:1,unit:"px"},type:i.LineType.SOLID},bottom:{color:"#cccccc",width:{value:1,unit:"px"},type:i.LineType.SOLID},left:{color:"#cccccc",width:{value:1,unit:"px"},type:i.LineType.SOLID}},Te=l.memo(({blockSizePx:e,blockZIndex:t,subZIndex:n=i.BLOCK_SUB_INDEX.GUIDE,borderStyle:r=Ne,visible:s=!0})=>{if(!s||!r)return null;const{top:c,right:d,bottom:o,left:f}=r;if(!c&&!d&&!o&&!f)return null;const{width:g,height:a}=e,u=me(t,n);return h.jsxs("svg",{role:"presentation","aria-hidden":"true",style:{position:"absolute",inset:0,width:`${g}px`,height:`${a}px`,pointerEvents:"none",overflow:"visible",zIndex:u},width:g,height:a,"data-testid":"block-guide-border",children:[c&&h.jsx("line",{x1:0,y1:0,x2:g,y2:0,stroke:c.color,strokeWidth:c.width.value,strokeDasharray:be(c.type,c.width.value)}),d&&h.jsx("line",{x1:g,y1:0,x2:g,y2:a,stroke:d.color,strokeWidth:d.width.value,strokeDasharray:be(d.type,d.width.value)}),o&&h.jsx("line",{x1:0,y1:a,x2:g,y2:a,stroke:o.color,strokeWidth:o.width.value,strokeDasharray:be(o.type,o.width.value)}),f&&h.jsx("line",{x1:0,y1:0,x2:0,y2:a,stroke:f.color,strokeWidth:f.width.value,strokeDasharray:be(f.type,f.width.value)})]})});Te.displayName="BlockGuideBorder";const kn=({id:e,resolvedPlugin:t,props:n,value:r,onChange:s,onBlur:c,readOnly:d,mode:o,blockSizePx:f,blockZIndex:g,subZIndex:a=i.BLOCK_SUB_INDEX.CONTENT,onMeasureHeight:u,onMeasureWidth:y,bindingContext:w,actionContext:b},x)=>{const R=l.useRef(null);l.useImperativeHandle(x,()=>({focus:()=>{var S;return(S=R.current)==null?void 0:S.focus()}}),[]);const m=me(g,a),v={position:"absolute",inset:0,width:`${f.width}px`,height:`${f.height}px`,zIndex:m,pointerEvents:"auto"},P={id:e,props:n,value:r,onChange:s??(()=>{}),onBlur:c,readOnly:d,mode:o,dimensions:{widthPx:f.width,heightPx:f.height},onMeasureHeight:u,onMeasureWidth:y,ariaLabel:t.meta.displayName,bindingContext:w,actionContext:b},{Renderer:O}=t;return h.jsx("div",{style:v,"data-testid":"block-renderer","data-block-id":e,"data-plugin-kind":t.kind,children:h.jsx(O,{ref:R,...P})})},xe=l.memo(l.forwardRef(kn));xe.displayName="BlockRenderer";function Xe(e,t,n){const r=(n==null?void 0:n[e.kind])??{};return{...t.defaultProps,...r,...e.props}}const Ze=l.memo(({blockSizePx:e,blockZIndex:t,errors:n})=>{const[r,s]=l.useState(!1);if(n.length===0)return null;const c=me(t,i.BLOCK_SUB_INDEX.VALIDATION),d=3,o="repeating-linear-gradient(45deg, #1a1a1a 0px, #1a1a1a 4px, #FFD700 4px, #FFD700 8px)",f={position:"absolute",top:-d,left:-d,width:`${e.width+d*2}px`,height:`${e.height+d*2}px`,zIndex:c,pointerEvents:"none"},g=a=>({position:"absolute",background:o,...a});return h.jsxs("div",{style:f,"data-testid":"validation-overlay",children:[h.jsx("div",{style:g({top:0,left:0,width:"100%",height:d})}),h.jsx("div",{style:g({bottom:0,left:0,width:"100%",height:d})}),h.jsx("div",{style:g({top:0,left:0,width:d,height:"100%"})}),h.jsx("div",{style:g({top:0,right:0,width:d,height:"100%"})}),h.jsxs("button",{type:"button",style:{position:"absolute",top:-8,right:-8,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,lineHeight:1,cursor:"default",pointerEvents:"auto",userSelect:"none",background:"none",border:"none",padding:0},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),"aria-label":n.map(a=>a.message).join(" / "),children:["⚠",r&&h.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",right:0,minWidth:160,maxWidth:240,backgroundColor:"rgba(30,30,30,0.92)",color:"#fff",fontSize:11,lineHeight:1.5,padding:"6px 8px",borderRadius:4,boxShadow:"0 2px 6px rgba(0,0,0,0.4)",pointerEvents:"none",whiteSpace:"pre-wrap",wordBreak:"break-all",zIndex:c+1},children:n.map(a=>h.jsx("div",{children:a.message},a.code))})]}),h.jsx("style",{children:'@media print { [data-testid="validation-overlay"] { display: none !important; } }'})]})});Ze.displayName="ValidationOverlay";const Ye=l.memo(l.forwardRef(({block:e,resolvedPlugin:t,blockRectPx:n,blockZIndex:r,mode:s,value:c,blockDefaults:d,onValueChange:o,onBlur:f,showGuides:g=!0,showBorder:a=!0,defaultGuideBorder:u=Ne,dpi:y=i.DEFAULT_DPI,pointerEvents:w="none",showValidation:b=!1,validationErrors:x,onMeasureHeight:R,onMeasureWidth:m,focusedBlockId:v,bindingContext:P,actionContext:O},S)=>{var $,z,j,k;const[L,N]=l.useState(null),[I,M]=l.useState(null),C=l.useCallback(D=>{N(D),R==null||R(e.id,D)},[e.id,R]),H=l.useCallback(D=>{M(D),m==null||m(e.id,D)},[e.id,m]),q=R?Math.max(n.height,L??0):n.height,J=m?Math.max(n.width,I??0):n.width,te={position:"absolute",left:`${n.left}px`,top:`${n.top}px`,width:`${J}px`,height:`${q}px`,zIndex:r,pointerEvents:w,boxSizing:"border-box"},W=l.useMemo(()=>({width:J,height:q}),[J,q]),A=Xe(e,t,d),E=t.validateProps?t.validateProps(A):A,T=t.validateValue?t.validateValue(c,E)??e.initValue??c:c,F=x&&x.length>0,p=F?`error-${e.id}`:void 0,_=v===e.id;return h.jsxs("section",{"aria-label":t.meta.displayName,"aria-invalid":F||void 0,"aria-describedby":p,style:te,"data-testid":`block-${e.id}`,"data-block-id":e.id,children:[h.jsx(ye,{blockSizePx:W,blockZIndex:r,backgroundColor:($=e.style)==null?void 0:$.backgroundColor,subZIndex:i.BLOCK_SUB_INDEX.BG}),g&&!((z=e.style)!=null&&z.border)&&h.jsx(Te,{blockSizePx:W,blockZIndex:r,subZIndex:i.BLOCK_SUB_INDEX.GUIDE,borderStyle:u}),h.jsx(xe,{ref:S,id:e.id,resolvedPlugin:t,props:E,value:T,onChange:o,onBlur:f,readOnly:s===i.NoteMode.EDIT?((j=e.behavior)==null?void 0:j.readOnly)??!1:!0,mode:s,blockSizePx:W,blockZIndex:r,subZIndex:i.BLOCK_SUB_INDEX.CONTENT,onMeasureHeight:R?C:void 0,onMeasureWidth:m?H:void 0,bindingContext:P,actionContext:O}),h.jsx(ce,{blockSizePx:W,blockZIndex:r,borderStyle:(k=e.style)==null?void 0:k.border,subZIndex:i.BLOCK_SUB_INDEX.BORDER,visible:a,dpi:y}),b&&F&&h.jsx(Ze,{blockSizePx:W,blockZIndex:r,errors:x}),F&&h.jsx("span",{id:p,style:{position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0},children:x.map(D=>D.message).join(", ")}),_&&h.jsx("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,boxShadow:"0 0 0 2px #3b82f6, 0 0 0 4px rgba(59,130,246,0.15)",pointerEvents:"none",zIndex:i.Z_INDEX.HOVER_OUTLINE,boxSizing:"border-box"}})]})}),(e,t)=>e.block===t.block&&e.resolvedPlugin===t.resolvedPlugin&&e.blockRectPx.left===t.blockRectPx.left&&e.blockRectPx.top===t.blockRectPx.top&&e.blockRectPx.width===t.blockRectPx.width&&e.blockRectPx.height===t.blockRectPx.height&&e.blockZIndex===t.blockZIndex&&e.mode===t.mode&&e.value===t.value&&e.blockDefaults===t.blockDefaults&&e.showGuides===t.showGuides&&e.showBorder===t.showBorder&&e.defaultGuideBorder===t.defaultGuideBorder&&e.dpi===t.dpi&&e.pointerEvents===t.pointerEvents&&e.showValidation===t.showValidation&&e.validationErrors===t.validationErrors&&e.onMeasureHeight===t.onMeasureHeight&&e.onMeasureWidth===t.onMeasureWidth&&e.focusedBlockId===t.focusedBlockId&&e.bindingContext===t.bindingContext&&e.actionContext===t.actionContext);Ye.displayName="BlockContainer";const Dn=(e,t)=>{},In=(e,t)=>{},ve=l.memo(({blocks:e,pluginRegistry:t,mode:n,values:r,blockDefaults:s,selectedBlockIds:c=[],getBlockRectPx:d,onValueChange:o,onBlur:f,showGuides:g=!0,showBorder:a=!0,defaultGuideBorder:u=Ne,dpi:y=i.DEFAULT_DPI,showValidation:w=!1,validationErrors:b,onMeasureHeight:x,onMeasureWidth:R,focusedBlockId:m,bindingContext:v,actionContext:P})=>{const O=l.useRef(new Map),S={position:"absolute",inset:0,pointerEvents:"none"};return h.jsx("div",{style:S,"data-testid":"block-layer",children:e.map((L,N)=>{var T,F;const I=t[L.kind];if(!I)return console.warn(`[tatamicks] Block kind "${L.kind}" is not registered. Add the plugin to createPluginRegistry.`),null;if(he(L.hiddenBinding,v))return null;const C=d(L),q=c.includes(L.id)?i.Z_INDEX.SELECT_BLOCK:Yt(N),J=L.props!==null&&typeof L.props=="object"&&"binding"in L.props?L.props.binding:void 0,te=J&&v?v.get(J)??null:L.id in r?r[L.id]:L.initValue??null,W=J&&v?p=>v.set(J,p):o?p=>o(L.id,p):void 0,A=(T=L.behavior)!=null&&T.heightFit?x??Dn:void 0,E=(F=L.behavior)!=null&&F.widthFit?R??In:void 0;return h.jsx(l.Fragment,{children:h.jsx(Ye,{ref:p=>{p?O.current.set(L.id,p):O.current.delete(L.id)},block:L,resolvedPlugin:I,blockRectPx:C,blockZIndex:q,mode:n,value:te??null,blockDefaults:s,onValueChange:W,onBlur:f?p=>f(L.id,p):void 0,showGuides:g,showBorder:a,defaultGuideBorder:u,dpi:y,pointerEvents:"none",showValidation:w,validationErrors:b==null?void 0:b[L.id],onMeasureHeight:A,onMeasureWidth:E,focusedBlockId:m,bindingContext:v,actionContext:P})},L.id)})})});ve.displayName="BlockLayer";function mt(e){if(!(e!=null&&e.width)||!(e!=null&&e.type))return;const t=e.width.value;if(t!==0){if(e.type===i.LineType.DASHED)return`${t*4} ${t*2}`;if(e.type===i.LineType.DOTTED)return`${t*1} ${t*2}`}}function Ee(e,t){return{stroke:e.color,strokeWidth:i.toPx.fromDim(e.width,t),strokeDasharray:mt(e)}}const yt=l.memo(({contentPx:e,marginLeftPx:t,marginTopPx:n,borderStyle:r,dpi:s=i.DEFAULT_DPI,zIndex:c=i.Z_INDEX.BORDER_OVERLAY})=>{if(!r)return null;const{top:d,right:o,bottom:f,left:g}=r;if(!d&&!o&&!f&&!g)return null;const a=e.width,u=e.height;return h.jsxs("svg",{role:"presentation","aria-hidden":"true",style:{position:"absolute",left:`${t}px`,top:`${n}px`,pointerEvents:"none",overflow:"visible",zIndex:c},width:a,height:u,"data-testid":"border-overlay",children:[d&&h.jsx("line",{x1:0,y1:0,x2:a,y2:0,...Ee(d,s)}),o&&h.jsx("line",{x1:a,y1:0,x2:a,y2:u,...Ee(o,s)}),f&&h.jsx("line",{x1:0,y1:u,x2:a,y2:u,...Ee(f,s)}),g&&h.jsx("line",{x1:0,y1:0,x2:0,y2:u,...Ee(g,s)})]})});yt.displayName="BorderOverlay";const xt=l.memo(({canvasPx:e,backgroundColor:t="#ffffff",boxShadow:n="0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:r=i.Z_INDEX.GRID_CANVAS})=>h.jsx("div",{role:"presentation","aria-label":"Paper background","data-testid":"grid-canvas",style:{position:"absolute",inset:0,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:t,boxShadow:n,pointerEvents:"none",zIndex:r}}));xt.displayName="GridCanvas";const Rn="_label_er4b8_1",Sn={label:Rn},Cn="_editor_1xj3w_1",Pn="_input_1xj3w_14",Nn="_select_1xj3w_29",Tn="_button_1xj3w_45",ke={editor:Cn,input:Pn,select:Nn,button:Tn},Mn=["fr","px","mm","cm","pt","inch"];function Ln(e,t){if(t==="fr")return 1;switch(t){case"px":return e;case"mm":return Math.round(i.toMm.fromPx(e)*10)/10;case"cm":return Math.round(i.toMm.fromPx(e)/10*100)/100;case"inch":return Math.round(i.toMm.fromPx(e)/25.4*100)/100;case"pt":return Math.round(i.toMm.fromPx(e)/25.4*72*10)/10;default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}const vt=l.memo(({direction:e,dimension:t,currentPxSize:n,position:r,marginLeftPx:s,marginTopPx:c,onChange:d,onCancel:o})=>{const[f,g]=l.useState(t.value.toString()),[a,u]=l.useState(t.unit),y=l.useRef(null),w=l.useRef(null),b=e==="column"?{left:`${s+r}px`,top:`${c+24}px`,transform:"translateX(-50%)"}:{left:`${s+24}px`,top:`${c+r}px`,transform:"translateY(-50%)"};l.useEffect(()=>{var v,P;(v=y.current)==null||v.focus(),(P=y.current)==null||P.select()},[]),l.useEffect(()=>{const v=P=>{w.current&&!w.current.contains(P.target)&&o()};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);const x=()=>{const v=Number.parseFloat(f);!Number.isNaN(v)&&v>=.1?d({unit:a,value:v}):o()},R=v=>{v.key==="Enter"?(v.preventDefault(),x()):v.key==="Escape"&&(v.preventDefault(),o())},m=v=>{const P=v.target.value;u(P),g(Ln(n,P).toString())};return h.jsxs("div",{ref:w,className:ke.editor,style:b,"data-testid":`grid-unit-editor-${e}`,children:[h.jsx("input",{ref:y,type:"number",className:ke.input,value:f,onChange:v=>g(v.target.value),onKeyDown:R,min:"0.1",step:a==="fr"?"0.1":"1"}),h.jsx("select",{className:ke.select,value:a,onChange:m,children:Mn.map(v=>h.jsx("option",{value:v,children:v},v))}),h.jsx("button",{type:"button",className:ke.button,onClick:x,title:"確定",children:"✓"})]})});vt.displayName="GridUnitEditor";function Bn(e,t,n,r){if(t==="fr")return n!==void 0&&r!==void 0&&r>0?Math.round(n*(e/r)*100)/100:1;switch(t){case"px":return Math.round(e);case"mm":return Math.round(i.toMm.fromPx(e)*10)/10;case"cm":return Math.round(i.toMm.fromPx(e)/10*100)/100;case"inch":return Math.round(i.toMm.fromPx(e)/25.4*100)/100;case"pt":return Math.round(i.toMm.fromPx(e)/25.4*72*10)/10;default:{const s=t;throw new Error(`Unsupported unit: ${s}`)}}}const Oe=l.memo(({direction:e,index:t,dimension:n,position:r,currentPxSize:s,marginLeftPx:c,marginTopPx:d,isNearCursor:o,resizingPxSize:f,onDimensionChange:g})=>{const[a,u]=l.useState(!1);if(!o&&!a)return null;const y=e==="column"?{left:`${c+r}px`,top:`${d-20}px`,transform:"translateX(-50%)"}:{left:`${c-20}px`,top:`${d+r}px`,transform:"translateY(-50%)",writingMode:"vertical-rl"},b=f?(()=>{const x=Bn(f,n.unit,n.value,s);return n.unit==="fr"?`${x}fr`:`${x}${n.unit}`})():(x=>x.unit==="fr"?`${x.value}fr`:`${x.value}${x.unit}`)(n);return h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",className:Sn.label,style:y,onDoubleClick:()=>u(!0),"data-testid":`grid-dimension-${e}-${t}`,"aria-label":`グリッド寸法: ${b}`,children:b}),a&&h.jsx(vt,{direction:e,dimension:n,currentPxSize:s,position:r,marginLeftPx:c,marginTopPx:d,onChange:x=>{g==null||g(e,t,x),u(!1)},onCancel:()=>u(!1)})]})});Oe.displayName="GridDimensionLabel";function An(e,t,n,r){let s="";for(const c of e)s+=`M ${c} 0 L ${c} ${r} `;for(const c of t)s+=`M 0 ${c} L ${n} ${c} `;return s}const wt=l.memo(({gridPosPx:e,contentPx:t,marginLeftPx:n,marginTopPx:r,lineStyle:s,zIndex:c=i.Z_INDEX.GRID_OVERLAY,dpi:d=i.DEFAULT_DPI})=>{const o=l.useMemo(()=>An(e.cols.slice(1,-1),e.rows.slice(1,-1),t.width,t.height),[e,t]);return s?h.jsx("svg",{style:{position:"absolute",left:`${n}px`,top:`${r}px`,pointerEvents:"none",zIndex:c},width:t.width,height:t.height,role:"img","aria-label":"Grid overlay lines",children:h.jsx("path",{d:o,stroke:s.color,strokeWidth:i.toPx.fromDim(s.width,d),strokeDasharray:mt(s),fill:"none"})}):null});wt.displayName="GridOverlay";const _n="_handle_i8g0e_1",On="_dragging_i8g0e_19",st={handle:_n,dragging:On},ze=l.memo(({direction:e,index:t,position:n,marginLeftPx:r,marginTopPx:s,onResizeStart:c,onResize:d,onResizeEnd:o})=>{const[f,g]=l.useState(!1),a=12,u=a/2,y=e==="column"?{left:`${r+n-u}px`,top:`${s-u}px`,width:`${a}px`,height:`${a}px`,cursor:"col-resize"}:{left:`${r-u}px`,top:`${s+n-u}px`,width:`${a}px`,height:`${a}px`,cursor:"row-resize"},w=l.useCallback(b=>{b.stopPropagation(),b.preventDefault();const x=e==="column"?b.clientX:b.clientY;g(!0),c==null||c(e,t);const R=v=>{const P=e==="column"?v.clientX:v.clientY;d==null||d(e,t,P-x)},m=v=>{const P=e==="column"?v.clientX:v.clientY;g(!1),o==null||o(e,t,P-x),window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",m)};window.addEventListener("pointermove",R),window.addEventListener("pointerup",m)},[e,t,c,d,o]);return h.jsx("div",{className:`${st.handle} ${f?st.dragging:""}`,style:y,onPointerDown:w,"data-testid":`grid-resize-handle-${e}-${t}`})});ze.displayName="GridResizeHandle";const bt=l.memo(({paperPx:e,marginColor:t="rgba(0, 0, 0, 0.05)",zIndex:n=i.Z_INDEX.MARGIN_OVERLAY})=>{const r={position:"absolute",backgroundColor:t,pointerEvents:"none"};return h.jsxs("div",{role:"presentation","aria-label":"Printable area margin","data-testid":"margin-overlay",style:{position:"absolute",inset:0,pointerEvents:"none",width:`${e.canvas.width}px`,height:`${e.canvas.height}px`,zIndex:n},children:[e.margin.top>0&&h.jsx("div",{"data-testid":"margin-top",style:{...r,top:0,left:0,width:"100%",height:`${e.margin.top}px`}}),e.margin.bottom>0&&h.jsx("div",{"data-testid":"margin-bottom",style:{...r,bottom:0,left:0,width:"100%",height:`${e.margin.bottom}px`}}),e.margin.left>0&&h.jsx("div",{"data-testid":"margin-left",style:{...r,left:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.left}px`}}),e.margin.right>0&&h.jsx("div",{"data-testid":"margin-right",style:{...r,right:0,top:`${e.margin.top}px`,height:`${e.content.height}px`,width:`${e.margin.right}px`}})]})});bt.displayName="MarginOverlay";const Me=l.memo(({paperPx:e,gridPosPx:t,gridDimensions:n,gridLineStyle:r,borderStyle:s,backgroundColor:c="#ffffff",boxShadow:d="0 2px 8px rgba(0, 0, 0, 0.1)",marginFillColor:o,showGridLines:f=!0,showMargins:g=!0,showBorder:a=!0,showResizeHandles:u=!1,showDimensionLabels:y=!1,dpi:w=i.DEFAULT_DPI,onGridResize:b,onDimensionChange:x,className:R="",zIndex:m={}})=>{const[v,P]=l.useState(null),[O,S]=l.useState(null),[L,N]=l.useState(null),I=l.useRef(null);l.useEffect(()=>{const W=E=>{if(!I.current)return;const T=I.current.getBoundingClientRect();N({x:E.clientX-T.left,y:E.clientY-T.top})},A=E=>{if(!I.current)return;const T=I.current.getBoundingClientRect();(E.clientX<T.left||E.clientX>T.right||E.clientY<T.top||E.clientY>T.bottom)&&N(null)};return window.addEventListener("mousemove",W),window.addEventListener("mouseleave",A),()=>{window.removeEventListener("mousemove",W),window.removeEventListener("mouseleave",A)}},[]);const M=l.useMemo(()=>L?!(L.x>=e.margin.left&&L.x<=e.margin.left+e.content.width&&L.y>=e.margin.top&&L.y<=e.margin.top+e.content.height):!1,[L,e]),C=l.useMemo(()=>{if(!v||!O)return null;const W=O.direction==="column"?t.cols:t.rows,A=O.index,E=W[A-1],T=W[A+1];return{direction:O.direction,prevIndex:A-1,prevSize:E!==void 0?v.position-E:0,nextIndex:A,nextSize:T!==void 0?T-v.position:0}},[v,O,t]),H=l.useCallback((W,A,E)=>{const F=W==="column"?t.cols:t.rows,p=F[A];if(p===void 0)return E;const _=F[A-1],$=F[A+1];let z=E;return _!==void 0&&(z=Math.max(z,_+10-p)),$!==void 0&&(z=Math.min(z,$-10-p)),z},[t]),q=l.useCallback((W,A)=>{S({direction:W,index:A})},[]),J=l.useCallback((W,A,E)=>{const F=(W==="column"?t.cols:t.rows)[A];F!==void 0&&P({direction:W,position:F+H(W,A,E)})},[t,H]),te=l.useCallback((W,A,E)=>{P(null),S(null),b==null||b(W,A,H(W,A,E))},[H,b]);return h.jsxs("div",{ref:I,className:R,style:{position:"relative",width:"100%",height:"100%"},children:[h.jsx(xt,{canvasPx:e.canvas,backgroundColor:c,boxShadow:d,zIndex:m.canvas??i.Z_INDEX.GRID_CANVAS}),g&&h.jsx(bt,{paperPx:e,marginColor:o,zIndex:m.margin??i.Z_INDEX.MARGIN_OVERLAY}),f&&h.jsx(wt,{gridPosPx:t,contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,lineStyle:r,dpi:w,zIndex:m.grid??i.Z_INDEX.GRID_OVERLAY}),a&&h.jsx(yt,{contentPx:e.content,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,borderStyle:s,dpi:w,zIndex:m.border??i.Z_INDEX.BORDER_OVERLAY}),u&&b&&h.jsxs(h.Fragment,{children:[t.cols.map((W,A)=>A===0||A===t.cols.length-1?null:h.jsx(ze,{direction:"column",index:A,position:W,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:q,onResize:J,onResizeEnd:te},`col-${W}`)),t.rows.map((W,A)=>A===0||A===t.rows.length-1?null:h.jsx(ze,{direction:"row",index:A,position:W,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,onResizeStart:q,onResize:J,onResizeEnd:te},`row-${W}`))]}),y&&n&&h.jsxs(h.Fragment,{children:[n.cols.map((W,A)=>{const E=t.cols[A],T=t.cols[A+1];if(E===void 0||T===void 0)return null;const F=(O==null?void 0:O.direction)==="column"&&(O.index===A||O.index===A+1);let p;return(C==null?void 0:C.direction)==="column"&&(C.prevIndex===A?p=C.prevSize:C.nextIndex===A&&(p=C.nextSize)),h.jsx(Oe,{direction:"column",index:A,dimension:W,position:(E+T)/2,currentPxSize:T-E,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:M||F,resizingPxSize:p,onDimensionChange:x},`col-dim-${E}`)}),n.rows.map((W,A)=>{const E=t.rows[A],T=t.rows[A+1];if(E===void 0||T===void 0)return null;const F=(O==null?void 0:O.direction)==="row"&&(O.index===A||O.index===A+1);let p;return(C==null?void 0:C.direction)==="row"&&(C.prevIndex===A?p=C.prevSize:C.nextIndex===A&&(p=C.nextSize)),h.jsx(Oe,{direction:"row",index:A,dimension:W,position:(E+T)/2,currentPxSize:T-E,marginLeftPx:e.margin.left,marginTopPx:e.margin.top,isNearCursor:M||F,resizingPxSize:p,onDimensionChange:x},`row-dim-${E}`)})]}),v&&h.jsx("div",{style:{position:"absolute",left:v.direction==="column"?e.margin.left+v.position:e.margin.left,top:v.direction==="row"?e.margin.top+v.position:e.margin.top,width:v.direction==="column"?"2px":e.content.width,height:v.direction==="row"?"2px":e.content.height,backgroundColor:"#3b82f6",opacity:.5,pointerEvents:"none",zIndex:i.Z_INDEX.GRID_GHOST}})]})});Me.displayName="GridLayer";function Et(e){return l.useState({editingBlockId:null,...e})}var ee=(e=>(e.IDLE="idle",e.PRESSING="pressing",e.DRAGGING="dragging",e.INSERT="insert",e.EDITING="editing",e))(ee||{}),K=(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))(K||{}),Q=(e=>(e.MOVE="move",e.RESIZE="resize",e.INSERT="insert",e))(Q||{});function kt(e){return e.editingBlockId!==null?"editing":e.dragging?e.dragging.type==="insert"?"insert":e.dragging.type==="resize"||e.dragging.currentGrid.col!==e.dragging.startGrid.col||e.dragging.currentGrid.row!==e.dragging.startGrid.row?"dragging":"pressing":"idle"}function Dt({layout:e,handle:t,deltaCol:n,deltaRow:r,gridCols:s,gridRows:c}){const d={...e};if(t===K.E||t===K.NE||t===K.SE){const o=s-e.x;d.w=Math.max(1,Math.min(e.w+n,o))}else if(t===K.W||t===K.NW||t===K.SW){const o=e.w-1,f=n>0?Math.min(n,o):n;e.x+f>=0?(d.x=e.x+f,d.w=e.w-f):(d.x=0,d.w=e.w+e.x)}if(t===K.S||t===K.SE||t===K.SW){const o=c-e.y;d.h=Math.max(1,Math.min(e.h+r,o))}else if(t===K.N||t===K.NE||t===K.NW){const o=e.h-1,f=r>0?Math.min(r,o):r;e.y+f>=0?(d.y=e.y+f,d.h=e.h-f):(d.y=0,d.h=e.h+e.y)}return d}function It(e,t,n,r,s){if(e.length===0)return[];if(e.length===1){const x=e[0];if(!x)return[];const R=r-x.layout.w,m=s-x.layout.h;return[{blockId:x.id,x:Math.max(0,Math.min(x.layout.x+t,R)),y:Math.max(0,Math.min(x.layout.y+n,m))}]}const c=Math.min(...e.map(x=>x.layout.x)),d=Math.min(...e.map(x=>x.layout.y)),o=Math.max(...e.map(x=>x.layout.x+x.layout.w)),f=Math.max(...e.map(x=>x.layout.y+x.layout.h)),g=o-c,a=f-d,u=Math.max(0,Math.min(c+t,r-g)),y=Math.max(0,Math.min(d+n,s-a)),w=u-c,b=y-d;return e.map(x=>({blockId:x.id,x:x.layout.x+w,y:x.layout.y+b}))}function fe(e,t){var n,r;return{id:He(e.kind),kind:e.kind,layout:{x:t.x,y:t.y,w:((n=e.meta.defaultSize)==null?void 0:n.w)??1,h:((r=e.meta.defaultSize)==null?void 0:r.h)??1},props:{}}}const zn={top:{color:"#888888",width:{value:3,unit:"px"},type:i.LineType.DASHED},right:{color:"#888888",width:{value:3,unit:"px"},type:i.LineType.DASHED},bottom:{color:"#888888",width:{value:3,unit:"px"},type:i.LineType.DASHED},left:{color:"#888888",width:{value:3,unit:"px"},type:i.LineType.DASHED}},Ie=l.memo(({block:e,resolvedPlugin:t,blockDefaults:n,rect:r,opacity:s,ghostZIndex:c})=>{var f,g,a;const d=Xe(e,t,n),o={width:r.width,height:r.height};return h.jsxs("div",{style:{position:"absolute",left:`${r.left}px`,top:`${r.top}px`,width:`${r.width}px`,height:`${r.height}px`,opacity:s,zIndex:c,pointerEvents:"none"},children:[h.jsx(ye,{blockSizePx:o,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.BG,backgroundColor:(f=e.style)==null?void 0:f.backgroundColor}),h.jsx(xe,{id:e.id,resolvedPlugin:t,props:d,value:e.initValue??null,readOnly:!0,mode:i.NoteMode.FORM,blockSizePx:o,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.CONTENT}),!((g=e.style)!=null&&g.border)&&h.jsx(Te,{blockSizePx:o,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.GUIDE,borderStyle:zn}),h.jsx(ce,{blockSizePx:o,borderStyle:(a=e.style)==null?void 0:a.border,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.BORDER,dpi:i.DEFAULT_DPI})]})});Ie.displayName="GhostBlock";const Rt=l.memo(({blocks:e,pluginRegistry:t,gridLength:n,draggingState:r,getBlockRectPx:s,blockDefaults:c,ghostZIndex:d=i.Z_INDEX.BLOCK_GHOST})=>{if(!r)return null;const o=r.currentGrid.col-r.startGrid.col,f=r.currentGrid.row-r.startGrid.row,g={position:"absolute",inset:0,pointerEvents:"none"};if(r.type===Q.MOVE){const a=r.blockIds.map(y=>e.find(w=>w.id===y)).filter(Boolean),u=It(a,o,f,n.cols,n.rows);return h.jsx("div",{style:g,"data-testid":"drag-layer-move",children:a.map(y=>{const w=t[y.kind];if(!w)return null;let b;const x=r.isOutside??!1,R=r.currentMousePx;if(x&&R){const m=s(y);b={left:R.x-m.width/2,top:R.y-m.height/2,width:m.width,height:m.height}}else{const m=u.find(P=>P.blockId===y.id);if(!m)return null;const v={...y,layout:{...y.layout,x:m.x,y:m.y}};b=s(v)}return h.jsx(Ie,{block:y,resolvedPlugin:w,blockDefaults:c,rect:b,opacity:x?.3:.5,ghostZIndex:d},y.id)})})}if(r.type===Q.RESIZE){const a=r.blockIds[0],u=r.handle;if(!a||!u)return null;const y=e.find(m=>m.id===a),w=y?t[y.kind]:void 0;if(!y||!w)return null;const b=Dt({layout:y.layout,handle:u,deltaCol:o,deltaRow:f,gridCols:n.cols,gridRows:n.rows}),x={...y,layout:b},R=s(x);return h.jsx("div",{style:g,"data-testid":"drag-layer-resize",children:h.jsx(Ie,{block:y,resolvedPlugin:w,blockDefaults:c,rect:R,opacity:r.isOutside?.3:.5,ghostZIndex:d})})}if(r.type===Q.INSERT){const{pluginKind:a,defaultSize:u,currentGrid:y,currentMousePx:w}=r;if(!a||!u)return null;const b=t[a];if(!b)return null;const x=r.isOutside??!1;let R;if(x&&w){const v=fe(b,{x:0,y:0}),P=s({...v,layout:{...v.layout,w:u.w,h:u.h}});R={left:w.x-P.width/2,top:w.y-P.height/2,width:P.width,height:P.height}}else{const v=n.cols-u.w,P=n.rows-u.h,O=Math.max(0,Math.min(y.col,v)),S=Math.max(0,Math.min(y.row,P)),L=fe(b,{x:O,y:S}),N={...L,layout:{...L.layout,w:u.w,h:u.h}};R=s(N)}const m={...fe(b,{x:0,y:0}),layout:{x:0,y:0,w:u.w,h:u.h}};return h.jsx("div",{style:g,"data-testid":"drag-layer-insert",children:h.jsx(Ie,{block:m,resolvedPlugin:b,blockDefaults:c,rect:R,opacity:x?.3:.5,ghostZIndex:d})})}return null});Rt.displayName="DragLayer";const jn=({id:e,resolvedPlugin:t,props:n,value:r,onChange:s,blockRectPx:c,block:d,zIndex:o=i.Z_INDEX.EDIT_BLOCK,bindingContext:f,actionContext:g},a)=>{var w,b;const u=l.useRef(null);l.useImperativeHandle(a,()=>({focus:()=>{var x;return(x=u.current)==null?void 0:x.focus()}}),[]);const y={width:c.width,height:c.height};return h.jsxs("div",{style:{position:"absolute",left:`${c.left}px`,top:`${c.top}px`,width:`${y.width}px`,height:`${y.height}px`,zIndex:o,pointerEvents:"auto"},"data-testid":"editing-block",children:[h.jsx(ye,{blockSizePx:y,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.BG,backgroundColor:(w=d.style)==null?void 0:w.backgroundColor}),h.jsx(xe,{ref:u,id:e,resolvedPlugin:t,props:n,value:r,onChange:s,readOnly:!1,mode:i.NoteMode.EDIT,blockSizePx:y,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.CONTENT,bindingContext:f,actionContext:g}),h.jsx(ce,{blockSizePx:y,borderStyle:(b=d.style)==null?void 0:b.border,blockZIndex:0,subZIndex:i.BLOCK_SUB_INDEX.BORDER,dpi:i.DEFAULT_DPI})]})},St=l.memo(l.forwardRef(jn));St.displayName="EditingBlock";const De={color:"#3b82f688",width:{value:4,unit:"px"},type:i.LineType.SOLID},Ct={top:De,right:De,bottom:De,left:De},je=12,se=je/2,$n=[{id:K.NW,cursor:"nwse-resize",x:0,y:0},{id:K.N,cursor:"ns-resize",x:50,y:0},{id:K.NE,cursor:"nesw-resize",x:100,y:0},{id:K.W,cursor:"ew-resize",x:0,y:50},{id:K.E,cursor:"ew-resize",x:100,y:50},{id:K.SW,cursor:"nesw-resize",x:0,y:100},{id:K.S,cursor:"ns-resize",x:50,y:100},{id:K.SE,cursor:"nwse-resize",x:100,y:100}],Pt=l.memo(({block:e,rect:t,showHandles:n=!1,onResizeStart:r,activeHandle:s,selectionStyle:c=Ct,selectBorderZIndex:d=i.Z_INDEX.BLOCK_SELECT_BORDER,blockHandlesZIndex:o=i.Z_INDEX.BLOCK_HANDLES})=>{const f={position:"absolute",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,pointerEvents:"none"};return h.jsxs("div",{style:f,"data-testid":"interaction-block","data-block-id":e.id,children:[h.jsx(ce,{blockSizePx:{width:t.width,height:t.height},borderStyle:c,blockZIndex:d,subZIndex:0,dpi:i.DEFAULT_DPI}),n&&r&&$n.map(({id:g,cursor:a,x:u,y})=>{const w=u===50?`calc(50% - ${se}px)`:u===100?`calc(100% - ${se}px)`:`-${se}px`,b=y===50?`calc(50% - ${se}px)`:y===100?`calc(100% - ${se}px)`:`-${se}px`,x=s===g;return h.jsx("div",{onPointerDown:R=>{R.stopPropagation(),r(R,g)},style:{position:"absolute",left:w,top:b,width:`${je}px`,height:`${je}px`,backgroundColor:x?"#3b82f6":"#ffffff",border:"1px solid #3b82f6",borderRadius:"50%",cursor:a,zIndex:o,pointerEvents:"auto",boxSizing:"border-box",transform:x?"scale(1.2)":void 0},"data-testid":`resize-handle-${g}`},g)})]})});Pt.displayName="InteractionBlock";const Nt=l.memo(({blocks:e,selectedBlockIds:t,isDragging:n,draggingState:r,getBlockRectPx:s,onResizeStart:c,selectionStyle:d=Ct,selectBorderZIndex:o,blockHandlesZIndex:f})=>{if(n&&(r==null?void 0:r.type)!==Q.RESIZE)return null;const a=Array.from(new Set(t));return h.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:a.map(u=>{const y=e.find(x=>x.id===u);if(!y)return null;const b=(r==null?void 0:r.type)===Q.RESIZE&&r.blockIds.includes(u)?r==null?void 0:r.handle:null;return h.jsx(Pt,{block:y,rect:s(y),showHandles:!0,onResizeStart:(x,R)=>c(x,R,u),activeHandle:b??null,selectionStyle:d,selectBorderZIndex:o,blockHandlesZIndex:f},y.id)})})});Nt.displayName="SelectionLayer";function Tt(e,t,n,r){const s=n-t.w,c=r-t.h;return{x:Math.max(0,Math.min(e.x,s)),y:Math.max(0,Math.min(e.y,c))}}function Gn(e,t,n){const r=e.x+e.w<t?e.x+1:Math.max(0,e.x-1),s=e.y+e.h<n?e.y+1:Math.max(0,e.y-1);return{x:r,y:s}}function lt(e,t,n){const{x:r,y:s}=e;for(let c=t.length-1;c>=0;c--){const d=t[c];if(!d)continue;const o=n(d);if(r>=o.left&&r<=o.left+o.width&&s>=o.top&&s<=o.top+o.height)return d.id}return null}const qe=l.memo(({page:e,pluginRegistry:t,gridLength:n,blockDefaults:r,getBlockRectPx:s,getColIndex:c,getRowIndex:d,state:o,onStateChange:f,selectedBlockIds:g,onSelectionChange:a,onPageChange:u,actionContext:y,bindingContext:w,scale:b=1,className:x="",selectionStyle:R})=>{const m=e.blocks,v=l.useRef(null),P=l.useRef(null),O=l.useRef(null);l.useEffect(()=>()=>{O.current!==null&&clearTimeout(O.current)},[]);const S=kt(o),L=l.useRef(null),N=l.useRef(0),I=l.useRef(null),M=l.useRef(0),C=l.useRef(o);C.current=o;const H=l.useRef(f);H.current=f,l.useEffect(()=>{if(S!==ee.INSERT)return;const p=_=>{const $=v.current;$&&(_.target===$||$.contains(_.target))||H.current({...C.current,dragging:void 0})};return window.addEventListener("pointerup",p),()=>window.removeEventListener("pointerup",p)},[S]),l.useEffect(()=>{if(S===ee.EDITING&&o.editingBlockId){const p=setTimeout(()=>{var _;(_=P.current)==null||_.focus()},0);return()=>clearTimeout(p)}},[S,o.editingBlockId]),l.useEffect(()=>{const p=new Set(m.map($=>$.id)),_=g.filter($=>p.has($));_.length!==g.length&&a(_)},[m,g,a]);const q=l.useCallback(p=>{var B;if(p.button!==0)return;const _=(B=v.current)==null?void 0:B.getBoundingClientRect();if(!_)return;const $=b,z={x:(p.clientX-_.left)/$,y:(p.clientY-_.top)/$},j=lt(z,m,s);if(S===ee.EDITING){j!==o.editingBlockId&&(f({...o,editingBlockId:null}),j||a([]));return}const k=c(z.x),D=d(z.y);if(j){p.stopPropagation();const V=g.includes(j);if(V&&p.shiftKey){a(g.filter(Y=>Y!==j));return}p.currentTarget.setPointerCapture(p.pointerId),V?f({...o,dragging:{type:Q.MOVE,blockIds:g,startGrid:{col:k,row:D},currentGrid:{col:k,row:D},isOutside:!1}}):p.shiftKey?a([...g,j]):(a([j]),f({...o,dragging:{type:Q.MOVE,blockIds:[j],startGrid:{col:k,row:D},currentGrid:{col:k,row:D},isOutside:!1}}))}else p.stopPropagation(),a([])},[m,s,c,d,S,g,a,f,b,o]),J=l.useCallback(p=>{var X;if(S!==ee.PRESSING&&S!==ee.DRAGGING&&S!==ee.INSERT||!o.dragging)return;const _=(X=v.current)==null?void 0:X.getBoundingClientRect();if(!_)return;const $=b,z=_.width/$,j=_.height/$,k=(p.clientX-_.left)/$,D=(p.clientY-_.top)/$,B=o.dragging.type!==Q.RESIZE&&(k<0||k>z||D<0||D>j),V=Math.max(0,Math.min(k,z)),Y=Math.max(0,Math.min(D,j));let G=c(V),Z=d(Y);if(o.dragging.type===Q.RESIZE&&o.dragging.handle){const U=o.dragging.handle;(U===K.E||U===K.NE||U===K.SE)&&(G=c(V)+1),(U===K.S||U===K.SE||U===K.SW)&&(Z=d(Y)+1)}f({...o,dragging:{...o.dragging,currentGrid:{col:G,row:Z},currentMousePx:{x:k,y:D},isOutside:B}})},[S,o,c,d,f,b]),te=l.useCallback(p=>{if((S===ee.DRAGGING||S===ee.INSERT)&&o.dragging){if(o.dragging.isOutside){if(o.dragging.type===Q.MOVE){const z=new Set(o.dragging.blockIds);u({...e,blocks:m.filter(j=>!z.has(j.id))}),a([])}f({...o,dragging:void 0}),p.currentTarget.releasePointerCapture(p.pointerId);return}const _=o.dragging.currentGrid.col-o.dragging.startGrid.col,$=o.dragging.currentGrid.row-o.dragging.startGrid.row;if(o.dragging.type===Q.MOVE&&(_!==0||$!==0)){const z=o.dragging.blockIds.map(j=>m.find(k=>k.id===j)).filter(Boolean);if(z.length>0){const j=It(z,_,$,n.cols,n.rows);u({...e,blocks:m.map(k=>{const D=j.find(B=>B.blockId===k.id);return D?{...k,layout:{...k.layout,x:D.x,y:D.y}}:k})})}}else if(o.dragging.type===Q.INSERT){const{pluginKind:z,currentGrid:j,defaultSize:k}=o.dragging;if(z&&k){const D=t[z];if(D){const{x:B,y:V}=Tt({x:j.col,y:j.row},{w:k.w,h:k.h},n.cols,n.rows),Y={...fe(D,{x:B,y:V}),layout:{x:B,y:V,w:k.w,h:k.h}};u({...e,blocks:[...m,Y]}),a([Y.id])}}}else if(o.dragging.type===Q.RESIZE){const z=o.dragging.blockIds[0],j=m.find(D=>D.id===z),k=o.dragging.handle;if(j&&k&&(_!==0||$!==0)){const D=Dt({layout:j.layout,handle:k,deltaCol:_,deltaRow:$,gridCols:n.cols,gridRows:n.rows});(D.x!==j.layout.x||D.y!==j.layout.y||D.w!==j.layout.w||D.h!==j.layout.h)&&u({...e,blocks:m.map(B=>B.id===j.id?{...B,layout:D}:B)})}}f({...o,dragging:void 0})}else if(S===ee.PRESSING&&o.dragging){if(o.dragging.isOutside&&o.dragging.type===Q.MOVE){const _=new Set(o.dragging.blockIds);u({...e,blocks:m.filter($=>!_.has($.id))}),a([])}f({...o,dragging:void 0})}p.currentTarget.releasePointerCapture(p.pointerId)},[S,o,m,e,n,t,u,f,a]),W=l.useCallback(p=>{var k;const _=(k=v.current)==null?void 0:k.getBoundingClientRect();if(!_)return;const $=b,z={x:(p.clientX-_.left)/$,y:(p.clientY-_.top)/$},j=lt(z,m,s);j&&(g.includes(j)||a([j]),f({...o,editingBlockId:j}))},[m,s,a,f,b,g,o]),A=l.useCallback(p=>{var _;if((S===ee.PRESSING||S===ee.DRAGGING||S===ee.INSERT)&&o.dragging){const $=(_=v.current)==null?void 0:_.getBoundingClientRect();if(!$)return;const z=b,j=(p.clientX-$.left)/z,k=(p.clientY-$.top)/z,D=$.width/z,B=$.height/z,V=Math.max(0,Math.min(j,D)),Y=Math.max(0,Math.min(k,B));f({...o,dragging:{...o.dragging,currentGrid:{col:c(V),row:d(Y)},currentMousePx:{x:j,y:k},isOutside:!0}})}},[S,o,b,c,d,f]),E=l.useCallback(p=>{const _=S===ee.EDITING;if(p.key==="Escape"){_?(p.preventDefault(),f({...o,editingBlockId:null}),O.current=setTimeout(()=>{var G;return(G=v.current)==null?void 0:G.focus()},0)):g.length>0&&(p.preventDefault(),a([]));return}if(_)return;if(p.key.toLowerCase()==="z"&&(p.ctrlKey||p.metaKey)&&!p.shiftKey){p.preventDefault(),y==null||y.execute("undo");return}if(p.key.toLowerCase()==="y"&&(p.ctrlKey||p.metaKey)||p.key.toLowerCase()==="z"&&(p.ctrlKey||p.metaKey)&&p.shiftKey){p.preventDefault(),y==null||y.execute("redo");return}if(p.key==="c"&&(p.ctrlKey||p.metaKey)&&g.length>0){p.preventDefault(),y.execute("copy");return}if(p.key==="x"&&(p.ctrlKey||p.metaKey)&&g.length>0){p.preventDefault(),y.execute("copy");const G=new Set(g);u({...e,blocks:m.filter(Z=>!G.has(Z.id))}),a([]);return}if(p.key==="v"&&(p.ctrlKey||p.metaKey)){y.isEnabled("paste")&&(p.preventDefault(),y.execute("paste"));return}if(p.key==="d"&&(p.ctrlKey||p.metaKey)&&g.length>0){p.preventDefault();const Z=m.filter(X=>g.includes(X.id)).map(X=>{const{x:U,y:ne}=Gn(X.layout,n.cols,n.rows);return{...X,id:He(X.kind),layout:{...X.layout,x:U,y:ne}}});u({...e,blocks:[...m,...Z]}),a(Z.map(X=>X.id));return}if((p.key==="Delete"||p.key==="Backspace")&&g.length>0){p.preventDefault();const G=new Set(g);u({...e,blocks:m.filter(Z=>!G.has(Z.id))}),a([]);return}if(p.key==="a"&&(p.ctrlKey||p.metaKey)){if(m.length===0)return;p.preventDefault(),a(m.map(G=>G.id));return}if(p.key==="Tab"){if(m.length===0)return;const G=[...m].sort((U,ne)=>U.layout.y!==ne.layout.y?U.layout.y-ne.layout.y:U.layout.x-ne.layout.x),Z=g.length===1?g[0]:null,X=Z!==null?G.findIndex(U=>U.id===Z):-1;if(p.shiftKey){if(X<=0){a([]);return}const U=G[X-1];if(!U)return;p.preventDefault(),a([U.id])}else if(X===-1){const U=G[0];if(!U)return;p.preventDefault(),a([U.id])}else if(X>=G.length-1){a([]);return}else{const U=G[X+1];if(!U)return;p.preventDefault(),a([U.id])}return}if(g.length===0)return;if(p.shiftKey){const Z={ArrowRight:{dw:1,dh:0},ArrowLeft:{dw:-1,dh:0},ArrowDown:{dw:0,dh:1},ArrowUp:{dw:0,dh:-1}}[p.key];if(!Z)return;p.preventDefault();const X=[...g].sort().join(","),U=I.current;(U===null||U.direction!==p.key||U.blockIds!==X)&&(M.current+=1,I.current={direction:p.key,blockIds:X,id:M.current});const ne=I.current;if(!ne)return;u({...e,blocks:m.map(ie=>{if(!g.includes(ie.id))return ie;const Ft=Math.max(1,Math.min(ie.layout.w+Z.dw,n.cols-ie.layout.x)),Ut=Math.max(1,Math.min(ie.layout.h+Z.dh,n.rows-ie.layout.y));return{...ie,layout:{...ie.layout,w:Ft,h:Ut}}})},{mergeKey:i.keyboardResizeKey(String(ne.id)),noTimeWindow:!0});return}const z={ArrowLeft:{deltaCol:-1,deltaRow:0},ArrowRight:{deltaCol:1,deltaRow:0},ArrowUp:{deltaCol:0,deltaRow:-1},ArrowDown:{deltaCol:0,deltaRow:1}}[p.key];if(!z||(p.preventDefault(),!m.filter(G=>g.includes(G.id)).every(G=>{const Z=G.layout.x+z.deltaCol,X=G.layout.y+z.deltaRow;return Z>=0&&Z+G.layout.w<=n.cols&&X>=0&&X+G.layout.h<=n.rows})))return;const D=[...g].sort().join(","),B=L.current;(B===null||B.direction!==p.key||B.blockIds!==D)&&(N.current+=1,L.current={direction:p.key,blockIds:D,id:N.current});const V=L.current;if(!V)return;const Y=String(V.id);u({...e,blocks:m.map(G=>g.includes(G.id)?{...G,layout:{...G.layout,x:G.layout.x+z.deltaCol,y:G.layout.y+z.deltaRow}}:G)},{mergeKey:i.arrowMoveKey(Y),noTimeWindow:!0})},[S,g,m,e,n,o,f,a,u,y]),T=l.useCallback((p,_,$)=>{S===ee.EDITING&&f({...o,editingBlockId:null}),p.currentTarget.setPointerCapture(p.pointerId);const z=m.find(D=>D.id===$);if(!z)return;const j=(()=>{switch(_){case K.E:case K.NE:case K.SE:return z.layout.x+z.layout.w;case K.W:case K.NW:case K.SW:return z.layout.x;default:return 0}})(),k=(()=>{switch(_){case K.S:case K.SE:case K.SW:return z.layout.y+z.layout.h;case K.N:case K.NE:case K.NW:return z.layout.y;default:return 0}})();f({...o,dragging:{type:Q.RESIZE,blockIds:[$],startGrid:{col:j,row:k},currentGrid:{col:j,row:k},handle:_,isOutside:!1}})},[S,o,m,f]),F=(()=>{if(!o.editingBlockId)return null;const p=m.find(z=>z.id===o.editingBlockId),_=p?t[p.kind]:null;if(!p||!_)return null;const $=Xe(p,_,r);return h.jsx(St,{ref:P,id:p.id,resolvedPlugin:_,props:$,value:p.initValue??null,onChange:z=>{u({...e,blocks:m.map(j=>j.id===p.id?{...j,initValue:z}:j)},{mergeKey:i.initValueKey(p.id)})},blockRectPx:s(p),block:p,bindingContext:w,actionContext:y})})();return h.jsxs("div",{ref:v,className:x,style:{position:"absolute",inset:0,zIndex:i.Z_INDEX.INTERACTION_LAYER_BASE,pointerEvents:"auto",touchAction:"none"},role:"application","aria-label":"Interactive canvas layer",tabIndex:-1,onPointerDown:q,onPointerMove:J,onPointerUp:te,onPointerLeave:A,onDoubleClick:W,onKeyDown:E,"data-testid":"interaction-layer",children:[F,h.jsx(Nt,{blocks:m,selectedBlockIds:g,isDragging:S===ee.DRAGGING,draggingState:o.dragging,getBlockRectPx:s,onResizeStart:T,selectionStyle:R}),h.jsx(Rt,{blocks:m,pluginRegistry:t,gridLength:n,draggingState:o.dragging,getBlockRectPx:s,blockDefaults:r,selectionStyle:R})]})});qe.displayName="InteractionLayer";const Le=l.createContext(null);function Se(e,t){switch(t){case"px":return Math.round(e);case"mm":return Math.round(i.toMm.fromPx(e)*10)/10;case"cm":return Math.round(i.toMm.fromPx(e)/10*100)/100;case"inch":return Math.round(i.toMm.fromPx(e)/25.4*100)/100;case"pt":return Math.round(i.toMm.fromPx(e)/25.4*72*10)/10;case"fr":return 1;default:{const n=t;throw new Error(`Unsupported unit: ${n}`)}}}function at(e,t,n,r,s){const c=e[t],d=e[t+1];if(!c||!d)return e;let o=0,f=0;for(const u of e)u.unit==="fr"?o+=u.value:f+=i.toPx.fromDim(u);const g=s-f,a=o>0?g/o:0;if(r==="next"){const u=i.toPx.fromDim(d),y=Math.max(10,u-n);e[t+1]={...d,value:Se(y,d.unit)};const w=g-(y-u),b=Math.max(10,c.value*a+n),x=o>0?b/w*o:1;e[t]={...c,value:Math.round(x*100)/100}}else{const u=i.toPx.fromDim(c),y=Math.max(10,u+n);e[t]={...c,value:Se(y,c.unit)};const w=g-(y-u),b=Math.max(10,d.value*a-n),x=o>0?b/w*o:1;e[t+1]={...d,value:Math.round(x*100)/100}}return e}function Hn(e,t,n){const r=e[t],s=e[t+1];if(!r||!s)return e;const c=Math.max(10,i.toPx.fromDim(r)+n),d=Math.max(10,i.toPx.fromDim(s)-n);return e[t]={...r,value:Se(c,r.unit)},e[t+1]={...s,value:Se(d,s.unit)},e}function Vn(e,t,n,r){const s=e[t],c=e[t+1];if(!s||!c)return e;const d=e.reduce((a,u)=>u.unit==="fr"?a+u.value:a,0),o=r/d,f=Math.max(10,s.value*o+n)/o,g=Math.max(10,c.value*o-n)/o;return e[t]={...s,value:Math.round(f*100)/100},e[t+1]={...c,value:Math.round(g*100)/100},e}function ct(e,t,n,r){if(t<0||t>=e.length)return e;const s=[...e],c=s[t],d=s[t+1];return!c||!d?e:c.unit==="fr"&&d.unit==="fr"?Vn(s,t,n,r):c.unit!=="fr"&&d.unit!=="fr"?Hn(s,t,n):c.unit==="fr"&&d.unit!=="fr"?at(s,t,n,"next",r):at(s,t,n,"current",r)}function Mt({book:e,pageIdx:t,showValidation:n,values:r,bindingContext:s}){const c=e.pages[t]??e.pages[0],d=e.paper,{paperPx:o,gridPosPx:f,getBlockRectPx:g}=i.useGridCalc(d,c.grid,i.DEFAULT_DPI),a=d.autoHeight===!0,u=d.autoWidth===!0,[y,w]=l.useState(new Map),[b,x]=l.useState(new Map),R=l.useCallback((I,M)=>{w(C=>{if(C.get(I)===M)return C;const H=new Map(C);return H.set(I,M),H})},[]),m=l.useCallback((I,M)=>{x(C=>{if(C.get(I)===M)return C;const H=new Map(C);return H.set(I,M),H})},[]),v=l.useMemo(()=>{if(!a||y.size===0)return 0;let I=0;for(const M of c.blocks){if(he(M.hiddenBinding,s))continue;const H=g(M),q=y.get(M.id)??H.height;I=Math.max(I,H.top-o.margin.top+q)}return I},[a,y,c.blocks,g,o.margin.top,s]),P=l.useMemo(()=>{if(!u||b.size===0)return 0;let I=0;for(const M of c.blocks){if(he(M.hiddenBinding,s))continue;const H=g(M),q=b.get(M.id)??H.width;I=Math.max(I,H.left-o.margin.left+q)}return I},[u,b,c.blocks,g,o.margin.left,s]),O=l.useMemo(()=>!a||v===0&&y.size===0?o.canvas.height:o.margin.top+Math.max(0,v)+o.margin.bottom,[a,o,v,y.size]),S=l.useMemo(()=>{const I=(f.cols[f.cols.length-1]??0)+o.margin.left+o.margin.right;if(!u||P===0&&b.size===0)return I;const M=o.margin.left+Math.max(0,P)+o.margin.right;return Math.max(I,M)},[u,o,f.cols,P,b.size]),L=l.useMemo(()=>({...o,canvas:{...o.canvas,height:O,width:S}}),[o,O,S]),N=l.useMemo(()=>{if(!n)return;const I={};for(const M of c.blocks){if(!dt(M.props))continue;const C=r[M.id],H=C==null?void 0:String(C),q=ft(M.props,H);q.length>0&&(I[M.id]=q)}return I},[n,c.blocks,r]);return{page:c,isFit:a,isWidthFit:u,paperPx:o,gridPosPx:f,getBlockRectPx:g,measuredHeights:y,measuredWidths:b,handleMeasureHeight:R,handleMeasureWidth:m,canvasHeightPx:O,canvasWidthPx:S,effectivePaperPx:L,validationErrors:N}}const Lt=l.memo(function({context:t,showValidation:n=!1,scale:r=1,className:s}){const{book:c,pluginRegistry:d}=t,o=t.values,f=t.onValuesChange,g=l.useCallback((C,H)=>f==null?void 0:f([{id:C,value:H}]),[f]),{page:a,isFit:u,isWidthFit:y,gridPosPx:w,getBlockRectPx:b,handleMeasureHeight:x,handleMeasureWidth:R,canvasHeightPx:m,canvasWidthPx:v,effectivePaperPx:P,validationErrors:O}=Mt({book:c,pageIdx:t.editorState.pageIdx,showValidation:n,values:o,bindingContext:t.bindingContext}),[S,L]=l.useState(null),N=l.useMemo(()=>[...a.blocks].sort((C,H)=>C.layout.y!==H.layout.y?C.layout.y-H.layout.y:C.layout.x-H.layout.x),[a.blocks]),I=l.useCallback(C=>{const H=C.target.closest("[data-block-id]");L((H==null?void 0:H.getAttribute("data-block-id"))??null)},[]),M=l.useCallback(C=>{C.currentTarget.contains(C.relatedTarget)||L(null)},[]);return h.jsx(Le.Provider,{value:d,children:h.jsxs("form",{"data-testid":"note-container","aria-label":"フォーム",className:s,onSubmit:C=>C.preventDefault(),onFocusCapture:I,onBlurCapture:M,style:{position:"relative",width:`${v}px`,height:`${m}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:r!==1?`scale(${r})`:void 0,transformOrigin:"top center"},children:[h.jsx(Me,{paperPx:P,gridPosPx:w,showGridLines:!1,showMargins:!1,showBorder:!1}),h.jsx(ve,{blocks:N,pluginRegistry:d,mode:i.NoteMode.EDIT,values:o,blockDefaults:a.blockDefaults,getBlockRectPx:b,onMeasureHeight:u?x:void 0,onMeasureWidth:y?R:void 0,onValueChange:f?g:void 0,showGuides:!0,showBorder:!0,showValidation:n,validationErrors:O,focusedBlockId:S??void 0,bindingContext:t.bindingContext,actionContext:t.actionContext})]})})}),Bt=l.memo(function({context:t,scale:n=1,className:r}){const{book:s,onBookChange:c,pluginRegistry:d}=t,o=t.editorState.pageIdx,f=t.editorState.selectedBlockIds,g=t.actionContext,a=s.pages[o]??s.pages[0],u=l.useRef(s);u.current=s;const y=l.useRef(o);y.current=o;const w=l.useCallback((k,D)=>{c&&c(gt(u.current,y.current,k),D)},[c]),[b,x]=Et(),R=l.useRef(x);R.current=x;const m=l.useCallback(k=>g.execute("selectBlocks",k),[g]),v=l.useRef(null),{expandedCols:P,expandedRows:O}=i.useExpandedGrid(a.grid),{paperPx:S,gridPosPx:L,getBlockRectPx:N,getColIndex:I,getRowIndex:M}=i.useGridCalc(s.paper,a.grid,i.DEFAULT_DPI),C=l.useCallback(k=>{var X;const D=i.getBlockDragKind(k);if(!D)return;k.preventDefault();const B=d[D],V=(B==null?void 0:B.meta.defaultSize)??{w:1,h:1},Y=(X=v.current)==null?void 0:X.getBoundingClientRect(),G=Y?I(k.clientX-Y.left):0,Z=Y?M(k.clientY-Y.top):0;R.current({editingBlockId:null,dragging:{type:Q.INSERT,blockIds:[],pluginKind:D,defaultSize:V,startGrid:{col:G,row:Z},currentGrid:{col:G,row:Z},currentMousePx:{x:k.clientX,y:k.clientY}}})},[d,I,M]),H=l.useCallback(k=>{var Y;if(!k.dataTransfer.types.includes(i.BLOCK_DRAG_MIME))return;k.preventDefault(),k.dataTransfer.dropEffect="copy";const D=(Y=v.current)==null?void 0:Y.getBoundingClientRect();if(!D)return;const B=I(k.clientX-D.left),V=M(k.clientY-D.top);R.current(G=>{var Z;return((Z=G.dragging)==null?void 0:Z.type)!==Q.INSERT?G:{...G,dragging:{...G.dragging,currentGrid:{col:B,row:V},currentMousePx:{x:k.clientX,y:k.clientY}}}})},[I,M]),q=l.useCallback(k=>{var D;k.dataTransfer.types.includes(i.BLOCK_DRAG_MIME)&&((D=v.current)!=null&&D.contains(k.relatedTarget)||R.current({editingBlockId:null,dragging:void 0}))},[]),J=l.useCallback(k=>{var ie;k.preventDefault();const D=i.getBlockDragData(k);if(!D)return;const B=(ie=v.current)==null?void 0:ie.getBoundingClientRect();if(!B)return;const V=I(k.clientX-B.left),Y=M(k.clientY-B.top),G=D.defaultSize??{w:1,h:1},Z=d[D.kind];if(!Z)return;const{x:X,y:U}=Tt({x:V,y:Y},G,a.grid.colCount,a.grid.rowCount),ne={...fe(Z,{x:X,y:U}),layout:{x:X,y:U,w:G.w,h:G.h}};w({...a,blocks:[...a.blocks,ne]}),m([ne.id]),R.current({editingBlockId:null,dragging:void 0})},[a,d,I,M,w,m]),[te,W]=l.useState(new Map),[A,E]=l.useState(new Map),T=l.useCallback((k,D)=>{W(B=>{if(B.get(k)===D)return B;const V=new Map(B);return V.set(k,D),V})},[]),F=l.useCallback((k,D)=>{E(B=>{if(B.get(k)===D)return B;const V=new Map(B);return V.set(k,D),V})},[]),p=l.useCallback(k=>{const D=N(k),B=te.get(k.id),V=A.get(k.id);return{...D,height:B!==void 0?Math.max(D.height,B):D.height,width:V!==void 0?Math.max(D.width,V):D.width}},[N,te,A]),_=l.useCallback((k,D)=>{const B=a.blocks.map(V=>V.id===k?{...V,initValue:D}:V);w({...a,blocks:B},{mergeKey:i.initValueKey(k)})},[a,w]);l.useEffect(()=>{const k=D=>{if(f.length===0)return;const B=D.target;if(B instanceof Element){const V=B.closest(i.SIDEBAR_PORTAL_SELECTOR),Y=B.closest('[data-selection-action-bar="true"]');if(V||Y)return}v.current&&!v.current.contains(B)&&m([])};return document.addEventListener("mousedown",k),()=>{document.removeEventListener("mousedown",k)}},[f,m]);const $=l.useCallback((k,D,B)=>{const V=D-1;if(k==="column"){const Y=ct(P,V,B,S.content.width);w({...a,grid:{...a.grid,...i.colsToSparse(Y)}})}else{const Y=ct(O,V,B,S.content.height);w({...a,grid:{...a.grid,...i.rowsToSparse(Y)}})}},[a,S,P,O,w]),z=l.useCallback((k,D,B)=>{if(k==="column"){const V=[...P];V[D]=B,w({...a,grid:{...a.grid,...i.colsToSparse(V)}})}else{const V=[...O];V[D]=B,w({...a,grid:{...a.grid,...i.rowsToSparse(V)}})}},[w,a,P,O]),j=l.useMemo(()=>{const k={};for(const D of a.blocks)!he(D.hiddenBinding,void 0)&&D.initValue!==void 0&&(k[D.id]=D.initValue);return k},[a.blocks]);return h.jsx(Le.Provider,{value:d,children:h.jsxs("section",{ref:v,"data-testid":"note-container",className:r,"aria-label":"用紙",onDragEnter:C,onDragOver:H,onDragLeave:q,onDrop:J,style:{position:"relative",width:`${S.canvas.width}px`,height:`${S.canvas.height}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:n!==1?`scale(${n})`:void 0,transformOrigin:"top center"},children:[h.jsx(Me,{paperPx:S,gridPosPx:L,gridDimensions:{cols:P,rows:O},showGridLines:!0,showMargins:!0,showBorder:!0,showResizeHandles:!0,showDimensionLabels:!0,onGridResize:$,onDimensionChange:z,gridLineStyle:{color:"#e5e7eb",width:{value:1,unit:"px"},type:i.LineType.SOLID},borderStyle:{top:{color:"#000000",width:{value:1,unit:"px"},type:i.LineType.SOLID},right:{color:"#000000",width:{value:1,unit:"px"},type:i.LineType.SOLID},bottom:{color:"#000000",width:{value:1,unit:"px"},type:i.LineType.SOLID},left:{color:"#000000",width:{value:1,unit:"px"},type:i.LineType.SOLID}}}),h.jsx(ve,{blocks:a.blocks,pluginRegistry:d,mode:i.NoteMode.FORM,values:j,selectedBlockIds:f,blockDefaults:a.blockDefaults,getBlockRectPx:N,onValueChange:_,onMeasureHeight:T,onMeasureWidth:F,showGuides:!0,showBorder:!0}),h.jsx(qe,{page:a,gridLength:{cols:a.grid.colCount,rows:a.grid.rowCount},pluginRegistry:d,blockDefaults:a.blockDefaults,getBlockRectPx:p,getColIndex:I,getRowIndex:M,selectedBlockIds:f,onSelectionChange:m,state:b,onStateChange:x,onPageChange:w,actionContext:g,scale:n})]})})}),At=l.memo(function(t){var S,L,N;const n=t.context!==void 0?t.context.book:t.book,r=t.context!==void 0?t.context.pluginRegistry:t.pluginRegistry,s=((S=t.context)==null?void 0:S.values)??t.values??{},c=t.showValidation??!1,d=t.scale??1,{className:o}=t,f=(L=t.context)==null?void 0:L.bindingContext,g=(N=t.context)==null?void 0:N.actionContext,{page:a,isFit:u,isWidthFit:y,gridPosPx:w,getBlockRectPx:b,handleMeasureHeight:x,handleMeasureWidth:R,canvasHeightPx:m,canvasWidthPx:v,effectivePaperPx:P,validationErrors:O}=Mt({book:n,pageIdx:t.context!==void 0?t.context.editorState.pageIdx:t.pageIdx??0,showValidation:c,values:s,bindingContext:f});return h.jsx(Le.Provider,{value:r,children:h.jsxs("div",{"data-testid":"note-container",className:o,style:{position:"relative",width:`${v}px`,height:`${m}px`,margin:"0 auto",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",backgroundColor:"#fff",transform:d!==1?`scale(${d})`:void 0,transformOrigin:"top center"},children:[h.jsx(Me,{paperPx:P,gridPosPx:w,showGridLines:!1,showMargins:!1,showBorder:!1}),h.jsx(ve,{blocks:a.blocks,pluginRegistry:r,mode:i.NoteMode.VIEW,values:s,blockDefaults:a.blockDefaults,getBlockRectPx:b,onMeasureHeight:u?x:void 0,onMeasureWidth:y?R:void 0,showGuides:!1,showBorder:!0,showValidation:c,validationErrors:O,bindingContext:f,actionContext:g})]})})});function _t({context:e,mode:t,className:n,style:r,showValidation:s,scale:c}){return t===i.NoteMode.FORM?h.jsx("div",{style:r,className:n,children:h.jsx(Bt,{scale:c,context:e})}):t===i.NoteMode.VIEW?h.jsx("div",{style:r,className:n,children:h.jsx(At,{showValidation:s,scale:c,context:e})}):h.jsx("div",{style:r,className:n,children:h.jsx(Lt,{showValidation:s,scale:c,context:e})})}function Ot(e,{actionContext:t,bindingContext:n,onChange:r}){if(typeof e=="string"){e&&t?t.execute(e):r(null);return}if(e!=null&&n!=null){n.set(e.path,e.value);return}r(null)}function zt(e,t){return typeof e!="string"||!e||!t?!0:t.isEnabled(e)}function jt(e,t){return e==null||typeof e!="object"||t==null?!1:t.get(e.path)===e.value}const $t={kind:"buttonContent",defaultProps:{label:"ボタン",icon:"",iconPath:"",title:""}},Gt={kind:"buttonAction",defaultProps:{action:""}},Ae={[i.HorizontalAlign.left]:"flex-start",[i.HorizontalAlign.center]:"center",[i.HorizontalAlign.right]:"flex-end"},_e={[i.VerticalAlign.top]:"flex-start",[i.VerticalAlign.center]:"center",[i.VerticalAlign.bottom]:"flex-end"},Qe=l.forwardRef(({props:e,readOnly:t,onChange:n,ariaLabel:r,actionContext:s,bindingContext:c},d)=>{const o=l.useRef(null),[f,g]=l.useState(!1);l.useImperativeHandle(d,()=>({focus:()=>{var m;return(m=o.current)==null?void 0:m.focus()}}),[]);const a=zt(e.action,s),u=t||!a,y=jt(e.action,c),w=l.useCallback(()=>{u||Ot(e.action,{actionContext:s,bindingContext:c,onChange:n})},[u,e.action,s,c,n]),b=l.useCallback(()=>{u||g(!0)},[u]),x=l.useCallback(()=>g(!1),[]),R=l.useMemo(()=>{const m={width:"100%",height:"100%",boxSizing:"border-box",overflow:"hidden",cursor:u?"default":"pointer",userSelect:"none",outline:"none",appearance:"none",border:"none",background:"none",opacity:u?.4:f?.7:y?.85:1,transform:f?"scale(0.97)":"scale(1)",transition:f?"none":"opacity 150ms ease, transform 150ms ease"};e.iconPath?(m.display="flex",m.alignItems=_e[e.vertical??i.VerticalAlign.center],m.justifyContent=Ae[e.horizontal??i.HorizontalAlign.center],m.containerType="size",m.color="inherit"):e.icon&&!e.label?(m.display="flex",m.alignItems=_e[e.vertical??i.VerticalAlign.center],m.justifyContent=Ae[e.horizontal??i.HorizontalAlign.center],m.containerType="size",m.fontFamily="inherit",m.color="inherit"):(m.display="flex",m.alignItems=_e[e.vertical??i.VerticalAlign.center],m.justifyContent=Ae[e.horizontal??i.HorizontalAlign.center],m.gap="4px",m.fontFamily="inherit",m.fontSize="inherit",m.color="inherit");const v=e.bulk?e.all:void 0,P=v??e.top,O=v??e.right,S=v??e.bottom,L=v??e.left;return P&&(m.paddingTop=i.dimensionToString(P)),O&&(m.paddingRight=i.dimensionToString(O)),S&&(m.paddingBottom=i.dimensionToString(S)),L&&(m.paddingLeft=i.dimensionToString(L)),m},[e,u,f,y]);return h.jsxs("button",{ref:o,type:"button",disabled:u,"aria-pressed":y?!0:void 0,"aria-label":r??e.label??"ボタン",title:e.title,style:R,onClick:w,onPointerDown:b,onPointerUp:x,onPointerLeave:x,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),w())},children:[e.iconPath?h.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",style:{display:"block",margin:"auto",width:"min(55cqi, 55cqb)",height:"min(55cqi, 55cqb)"},children:h.jsx("path",{d:e.iconPath,fill:"currentColor"})}):e.icon?h.jsx("span",{"aria-hidden":"true",style:e.label?void 0:{display:"block",width:"100%",textAlign:"center",fontSize:"min(55cqi, 55cqb)",lineHeight:"1"},children:e.icon}):null,!e.iconPath&&(e.label||!e.icon)&&h.jsx("span",{children:e.label??"ボタン"})]})});Qe.displayName="ButtonRenderer";const Wn={kind:"button",meta:{displayName:"ボタン",description:"クリックでアクションを実行するボタンブロック",defaultSize:{w:2,h:1}},Renderer:Qe,properties:[i.alignmentProp,pe,$t,Gt],validateProps:e=>typeof e!="object"||e===null?{}:e,validateValue:()=>null};function oe(e,t){return{id:e,kind:"text",layout:{x:0,y:0,w:1,h:1},props:{binding:t,placeholder:"0",pattern:"^[0-9]*\\.?[0-9]*$",multiline:!1,horizontal:"right",vertical:"center",top:{value:2,unit:"px"},right:{value:5,unit:"px"}}}}const Kn=[{label:"mm",value:"mm"},{label:"cm",value:"cm"},{label:"inch",value:"inch"}];function ge(e,t){return{id:e,kind:"select",layout:{x:0,y:0,w:1,h:1},props:{binding:t,selectConfig:{options:Kn,allowEmpty:!1,defaultValue:"mm"},horizontal:"left",left:{value:2,unit:"px"}}}}const Ht={kind:"stepperBehavior",defaultProps:{step:1}},Vt={kind:"stepperStyle",defaultProps:{styleConfig:{arrowWidth:50,arrowHeight:25,arrowColor:"currentColor",arrowGap:20}}};function Fn(e,t,n,r){let s=e+t;return r!==void 0&&(s=Math.min(r,s)),n!==void 0&&(s=Math.max(n,s)),s}const Un="M 10,0 L 20,10 L 0,10 Z",Xn="M 0,0 L 20,0 L 10,10 Z",ut=e=>({position:"absolute",left:0,width:"100%",height:"50%",padding:0,border:"none",background:"none",appearance:"none",cursor:e?"default":"pointer",boxSizing:"border-box"}),Je=l.forwardRef(({props:e,value:t,onChange:n,readOnly:r},s)=>{var S,L,N,I;const c=l.useRef(null),[d,o]=l.useState(!1),[f,g]=l.useState(!1),a=r,u=e.step??1,y=((S=e.styleConfig)==null?void 0:S.arrowColor)??"currentColor",w=((L=e.styleConfig)==null?void 0:L.arrowWidth)??50,b=((N=e.styleConfig)==null?void 0:N.arrowHeight)??25,x=((I=e.styleConfig)==null?void 0:I.arrowGap)??20,R=(100-w)/2;l.useImperativeHandle(s,()=>({focus:()=>{var M,C;return(C=(M=c.current)==null?void 0:M.querySelector("button"))==null?void 0:C.focus()}}),[]);const m=l.useCallback(M=>{if(a)return;const C=Number(t??0),H=Fn(C,M,e.min,e.max);n(H)},[a,t,n,e.min,e.max]),v=l.useCallback(()=>m(u),[m,u]),P=l.useCallback(()=>m(-u),[m,u]),O=M=>({opacity:a?.4:M?.6:1,transform:M?"scale(0.9)":"scale(1)",transition:M?"none":"opacity 150ms ease, transform 150ms ease"});return h.jsxs("div",{ref:c,style:{position:"relative",width:"100%",height:"100%",overflow:"visible",color:y},children:[h.jsx("button",{type:"button",disabled:a,"aria-label":"増やす",style:{...ut(a),top:0},onClick:v,onPointerDown:()=>{a||o(!0)},onPointerUp:()=>o(!1),onPointerLeave:()=>o(!1)}),h.jsx("button",{type:"button",disabled:a,"aria-label":"減らす",style:{...ut(a),bottom:0},onClick:P,onPointerDown:()=>{a||g(!0)},onPointerUp:()=>g(!1),onPointerLeave:()=>g(!1)}),h.jsx("svg",{viewBox:"0 0 20 10",preserveAspectRatio:"none","aria-hidden":"true",style:{position:"absolute",left:`${R}%`,bottom:`calc(50% + ${x/2}%)`,width:`${w}%`,height:`${b}%`,pointerEvents:"none",transformOrigin:"center bottom",...O(d)},children:h.jsx("path",{d:Un,fill:"currentColor"})}),h.jsx("svg",{viewBox:"0 0 20 10",preserveAspectRatio:"none","aria-hidden":"true",style:{position:"absolute",left:`${R}%`,top:`calc(50% + ${x/2}%)`,width:`${w}%`,height:`${b}%`,pointerEvents:"none",transformOrigin:"center top",...O(f)},children:h.jsx("path",{d:Xn,fill:"currentColor"})})]})});Je.displayName="StepperRenderer";const ue={kind:"stepper",meta:{displayName:"ステッパー",description:"数値を増減するステッパーブロック",defaultSize:{w:1,h:1}},Renderer:Je,properties:[i.alignmentProp,Ht,Vt],validateProps:e=>{if(typeof e!="object"||e===null)return{};const t=e;return"styleConfig"in t&&(typeof t.styleConfig!="object"||t.styleConfig===null)?{...t,styleConfig:{}}:e},validateValue:e=>typeof e=="number"?e:null},et={size:{preset:i.PaperSizePreset.CUSTOM,width:{value:100,unit:"mm"},height:{value:8,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},Wt={colCount:3,rowCount:1,cols:{2:{value:8,unit:"mm"}}},Zn={props:{book:{paper:et,pages:[{grid:Wt,blocks:[{id:"grid-row-count-label",kind:"text",layout:{x:0,y:0,w:1,h:1},initValue:"行数",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...oe("grid-row-count-value","grid.rowCount"),layout:{x:1,y:0,w:1,h:1}},{id:"grid-row-count-stepper",kind:"stepper",layout:{x:2,y:0,w:1,h:1},props:{binding:"grid.rowCount",step:1,min:1}}]}]}},plugins:[ae,ue]},Yn={props:{book:{paper:et,pages:[{grid:Wt,blocks:[{id:"grid-col-count-label",kind:"text",layout:{x:0,y:0,w:1,h:1},initValue:"列数",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...oe("grid-col-count-value","grid.colCount"),layout:{x:1,y:0,w:1,h:1}},{id:"grid-col-count-stepper",kind:"stepper",layout:{x:2,y:0,w:1,h:1},props:{binding:"grid.colCount",step:1,min:1}}]}]}},plugins:[ae,ue]},qn={props:{book:{paper:et,pages:[{grid:{colCount:6,rowCount:1,cols:{2:{value:8,unit:"mm"},5:{value:8,unit:"mm"}}},blocks:[{id:"grid-row-count-label",kind:"text",layout:{x:0,y:0,w:1,h:1},initValue:"行数",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...oe("grid-row-count-value","grid.rowCount"),layout:{x:1,y:0,w:1,h:1}},{id:"grid-row-count-stepper",kind:"stepper",layout:{x:2,y:0,w:1,h:1},props:{binding:"grid.rowCount",step:1,min:1}},{id:"grid-col-count-label",kind:"text",layout:{x:3,y:0,w:1,h:1},initValue:"列数",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{...oe("grid-col-count-value","grid.colCount"),layout:{x:4,y:0,w:1,h:1}},{id:"grid-col-count-stepper",kind:"stepper",layout:{x:5,y:0,w:1,h:1},props:{binding:"grid.colCount",step:1,min:1}}]}]}},plugins:[ae,ue]},Qn={get:()=>null,set:()=>{}},Jn={execute:()=>{},isEnabled:()=>!1},ei={selectedBlockIds:[],pageIdx:0},tt=l.forwardRef(({props:e,dimensions:t,bindingContext:n,actionContext:r,onMeasureHeight:s,onMeasureWidth:c},d)=>{const o=l.useContext(Le);l.useImperativeHandle(d,()=>({focus:()=>{}}),[]);const f=l.useRef(null),{naturalWidth:g,naturalHeight:a,scale:u}=l.useMemo(()=>{const w=i.toPx.fromDim(e.book.paper.size.width,i.DEFAULT_DPI),b=i.toPx.fromDim(e.book.paper.size.height,i.DEFAULT_DPI),x=t&&w>0&&b>0?Math.min(t.widthPx/w,t.heightPx/b<1&&b-t.heightPx<1?1:t.heightPx/b):1;return{naturalWidth:w,naturalHeight:b,scale:x}},[e.book.paper,t]);l.useEffect(()=>{s==null||s(a*u)},[s,a,u]),l.useEffect(()=>{c==null||c(g*u)},[c,g,u]);const y=l.useMemo(()=>o?{book:e.book,onBookChange:()=>{},pluginRegistry:o,containerRef:f,bindingContext:n??Qn,actionContext:r??Jn,editorState:ei,values:{}}:null,[e.book,o,n,r]);return y?h.jsx("div",{style:{width:"100%",height:"100%",overflow:"hidden"},children:h.jsx(_t,{mode:i.NoteMode.EDIT,context:y,style:{width:g,height:a,transform:`scale(${u})`,transformOrigin:"top left"}})}):null});tt.displayName="NoteBlockRenderer";const nt={kind:"note",meta:{displayName:"ノートブロック",description:"ブロックとして振る舞う Note(入れ子グリッド)",defaultSize:{w:6,h:4}},Renderer:tt,properties:[],validateProps:e=>typeof e=="object"&&e!==null&&"book"in e&&typeof e.book=="object"&&e.book!==null?e:{book:ht},validateValue:()=>null};const de={path:"paper.size.preset",neq:i.PaperSizePreset.CUSTOM},it={size:{preset:i.PaperSizePreset.CUSTOM,width:{value:160,unit:"mm"},height:{value:10,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},ti={book:{paper:it,pages:[{grid:{colCount:8,rowCount:1,cols:{7:{value:15,unit:"mm"}}},blocks:[{id:"paper-size-label",kind:"text",layout:{x:0,y:0,w:2,h:1},initValue:"用紙サイズ",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{id:"paper-preset",kind:"select",layout:{x:2,y:0,w:3,h:1},initValue:i.PaperSizePreset.A4,props:{binding:"paper.size.preset",required:!0,left:{value:2,unit:"px"},selectConfig:{options:[{label:"A4 (210×297mm)",value:i.PaperSizePreset.A4},{label:"A3 (297×420mm)",value:i.PaperSizePreset.A3},{label:"B5 (182×257mm)",value:i.PaperSizePreset.B5},{label:"Letter (8.5×11inch)",value:i.PaperSizePreset.LETTER},{label:"Legal (8.5×14inch)",value:i.PaperSizePreset.LEGAL},{label:"カスタム",value:i.PaperSizePreset.CUSTOM}]}}},{id:"paper-orientation-label",kind:"text",layout:{x:5,y:0,w:2,h:1},initValue:"横向き",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{id:"paper-orientation",kind:"checkbox",layout:{x:7,y:0,w:1,h:1},props:{binding:"paper.orientation"}}]}]}},ni={book:{paper:it,pages:[{grid:{colCount:8,rowCount:1,cols:{3:{value:15,unit:"mm"},7:{value:15,unit:"mm"}}},blocks:[{id:"paper-width-auto-label",kind:"text",layout:{x:0,y:0,w:3,h:1},initValue:"幅自動",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{id:"paper-width-auto",kind:"checkbox",layout:{x:3,y:0,w:1,h:1},props:{binding:"paper.autoWidth"}},{id:"paper-height-auto-label",kind:"text",layout:{x:4,y:0,w:3,h:1},initValue:"高さ自動",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"}},{id:"paper-height-auto",kind:"checkbox",layout:{x:7,y:0,w:1,h:1},props:{binding:"paper.autoHeight"}}]}]}},ii={book:{paper:it,pages:[{grid:{colCount:8,rowCount:1,cols:{2:{value:8,unit:"mm"},3:{value:15,unit:"mm"},6:{value:8,unit:"mm"},7:{value:15,unit:"mm"}}},blocks:[{id:"paper-width-label",kind:"text",layout:{x:0,y:0,w:1,h:1},initValue:"幅",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"},hiddenBinding:"paper.autoWidth"},{id:"paper-width-label-min",kind:"text",layout:{x:0,y:0,w:1,h:1},initValue:"最低幅",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"},hiddenBinding:{path:"paper.autoWidth",neq:!0}},{...oe("paper-width-value","paper.size.width.value"),layout:{x:1,y:0,w:1,h:1}},{id:"paper-width-stepper",kind:"stepper",layout:{x:2,y:0,w:1,h:1},props:{binding:"paper.size.width.value",step:1,min:0}},{...ge("paper-width-unit","paper.size.width.unit"),layout:{x:3,y:0,w:1,h:1}},{id:"paper-height-label",kind:"text",layout:{x:4,y:0,w:1,h:1},initValue:"高さ",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"},hiddenBinding:"paper.autoHeight"},{id:"paper-height-label-min",kind:"text",layout:{x:4,y:0,w:1,h:1},initValue:"最低高さ",behavior:{readOnly:!0},props:{horizontal:"center",vertical:"center"},hiddenBinding:{path:"paper.autoHeight",neq:!0}},{...oe("paper-height-value","paper.size.height.value"),layout:{x:5,y:0,w:1,h:1}},{id:"paper-height-stepper",kind:"stepper",layout:{x:6,y:0,w:1,h:1},props:{binding:"paper.size.height.value",step:1,min:0}},{...ge("paper-height-unit","paper.size.height.unit"),layout:{x:7,y:0,w:1,h:1}}]}]}},ri={props:{book:{paper:{size:{preset:i.PaperSizePreset.CUSTOM,width:{value:160,unit:"mm"},height:{value:30,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},pages:[{grid:{colCount:1,rowCount:3,rows:{0:{value:10,unit:"mm"},1:{value:10,unit:"mm"},2:{value:10,unit:"mm"}}},blocks:[{id:"row-preset-orientation",kind:"note",layout:{x:0,y:0,w:1,h:1},behavior:{heightFit:!0},props:ti},{id:"row-auto-resize",kind:"note",layout:{x:0,y:1,w:1,h:1},behavior:{heightFit:!0},props:ni},{id:"row-dimension",kind:"note",layout:{x:0,y:2,w:1,h:1},behavior:{heightFit:!0},props:ii,hiddenBinding:de}]}]}},plugins:[Ke,nt,Pe,ue,ae]},oi={props:{book:{paper:{size:{preset:i.PaperSizePreset.CUSTOM,width:{value:20,unit:"mm"},height:{value:15,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},pages:[{grid:{colCount:1,rowCount:1},blocks:[{id:"paper-orientation",kind:"checkbox",layout:{x:0,y:0,w:1,h:1},props:{binding:"paper.orientation"}}]}]}},plugins:[Ke]},si={props:{book:{paper:{size:{preset:i.PaperSizePreset.CUSTOM,width:{value:60,unit:"mm"},height:{value:10,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},pages:[{grid:{colCount:1,rowCount:1},blocks:[{id:"paper-preset",kind:"select",layout:{x:0,y:0,w:1,h:1},props:{binding:"paper.size.preset",selectConfig:{options:[{label:"A4 (210×297mm)",value:i.PaperSizePreset.A4},{label:"A3 (297×420mm)",value:i.PaperSizePreset.A3},{label:"B5 (182×257mm)",value:i.PaperSizePreset.B5},{label:"Letter (8.5×11inch)",value:i.PaperSizePreset.LETTER},{label:"Legal (8.5×14inch)",value:i.PaperSizePreset.LEGAL},{label:"カスタム",value:i.PaperSizePreset.CUSTOM}]}}}]}]}},plugins:[Pe]},Kt=[{id:"paper-preset",kind:"select",layout:{x:0,y:0,w:4,h:1},props:{binding:"paper.size.preset",selectConfig:{options:[{label:"A4 (210×297mm)",value:i.PaperSizePreset.A4},{label:"A3 (297×420mm)",value:i.PaperSizePreset.A3},{label:"B5 (182×257mm)",value:i.PaperSizePreset.B5},{label:"Letter (8.5×11inch)",value:i.PaperSizePreset.LETTER},{label:"Legal (8.5×14inch)",value:i.PaperSizePreset.LEGAL},{label:"カスタム",value:i.PaperSizePreset.CUSTOM}]}}},{...oe("paper-width-value","paper.size.width.value"),layout:{x:0,y:1,w:1,h:1},hiddenBinding:de},{...ge("paper-width-unit","paper.size.width.unit"),layout:{x:1,y:1,w:1,h:1},hiddenBinding:de},{...oe("paper-height-value","paper.size.height.value"),layout:{x:2,y:1,w:1,h:1},hiddenBinding:de},{...ge("paper-height-unit","paper.size.height.unit"),layout:{x:3,y:1,w:1,h:1},hiddenBinding:de}],li={props:{book:{paper:{size:{preset:i.PaperSizePreset.CUSTOM,width:{value:80,unit:"mm"},height:{value:30,unit:"mm"}},margin:{top:{value:0,unit:"mm"},right:{value:0,unit:"mm"},bottom:{value:0,unit:"mm"},left:{value:0,unit:"mm"}},autoHeight:!0,autoWidth:!0},pages:[{grid:{colCount:4,rowCount:2,cols:{1:{value:15,unit:"mm"},3:{value:15,unit:"mm"}}},blocks:Kt}]}},plugins:[nt,Pe,ue,ae]};exports.BlockBorder=ce;exports.BlockCanvas=ye;exports.BlockContainer=Ye;exports.BlockGuideBorder=Te;exports.BlockLayer=ve;exports.BlockRenderer=xe;exports.ButtonPlugin=Wn;exports.ButtonRenderer=Qe;exports.CheckboxPlugin=Ke;exports.CheckboxRenderer=We;exports.DEFAULT_BOOK=ht;exports.DEFAULT_GUIDE_BORDER=Ne;exports.DEFAULT_PAGE=Ve;exports.DragType=Q;exports.InteractionLayer=qe;exports.InteractionMode=ee;exports.Note=_t;exports.NoteBlockPlugin=nt;exports.NoteBlockRenderer=tt;exports.NoteEdit=Lt;exports.NoteForm=Bt;exports.NoteView=At;exports.PAPER_SIZE_BLOCKS=Kt;exports.ResizeHandle=K;exports.SelectPlugin=Pe;exports.SelectRenderer=Fe;exports.StepperPlugin=ue;exports.StepperRenderer=Je;exports.TextPlugin=ae;exports.TextRenderer=Ue;exports.ValidationOverlay=Ze;exports.ValidationSeverity=re;exports.addPage=Jt;exports.buildPageCss=an;exports.buttonActionProp=Gt;exports.buttonContentProp=$t;exports.cleanValues=on;exports.createBlockId=He;exports.ensurePageIds=en;exports.evalHiddenBinding=he;exports.evaluateCheckboxValidation=Zt;exports.evaluateValidation=ft;exports.executeButtonAction=Ot;exports.fontStyleProp=$e;exports.getButtonActionActive=jt;exports.getInteractionMode=kt;exports.getPaperSize=sn;exports.gridColCountWidget=Yn;exports.gridRowCountWidget=Zn;exports.gridSettingsWidget=qn;exports.hasValidationRule=dt;exports.insertPage=rn;exports.isButtonActionEnabled=zt;exports.movePage=nn;exports.numberInputBlock=oe;exports.paddingProp=pe;exports.paperOrientationWidget=oi;exports.paperPresetSelectWidget=si;exports.paperSettingsWidget=ri;exports.paperSizeWidget=li;exports.placeholderProp=Ge;exports.removePage=tn;exports.requiredProp=Ce;exports.resolveEffectivePaper=ln;exports.selectConfigProp=pt;exports.setPage=gt;exports.stepperBehaviorProp=Ht;exports.stepperStyleProp=Vt;exports.unitSelectBlock=ge;exports.useBookActionContext=mn;exports.useBookBindingContext=xn;exports.useBookHistory=bn;exports.useInteractionState=Et;exports.validateBook=Qt;
|