@hy-bricks/canvas 0.1.1
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/LICENSE +21 -0
- package/README.md +227 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +1982 -0
- package/dist/index.mjs +2 -0
- package/package.json +62 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode(".hc-canvas-stage[data-v-825e0ee8]{position:relative;width:100%;height:100%;overflow:hidden;background:#f1f5f9;isolation:isolate}.hc-canvas-stage__world[data-v-825e0ee8]{position:absolute;top:0;left:0;will-change:transform}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();
|
|
2
|
+
import{reactive as e,computed as n,inject as t,ref as o,readonly as i,provide as a,watch as r,defineComponent as s,onMounted as c,nextTick as d,onBeforeUnmount as l,shallowRef as u,openBlock as p,createElementBlock as f,normalizeStyle as h,unref as g,createCommentVNode as v,Fragment as y,renderList as m,withDirectives as I,createElementVNode as w,toDisplayString as x,createBlock as b,vShow as k,Teleport as S,renderSlot as M,createVNode as T,withCtx as z,createSlots as B,normalizeProps as L,guardReactiveProps as P}from"vue";import{registryVersion as C,getInstance as $,listInstances as E,HC_CANVAS_ID_KEY as O,DEFAULT_CANVAS_ID as D,disposeCanvas as R,RuntimeBox as A}from"@hy-bricks/core";function j(e){return JSON.parse(JSON.stringify(e))}const F="[hc-canvas/normalizeBindings]";function N(e){if(!Array.isArray(e))return[];const n=[];for(let t=0;t<e.length;t++){const o=e[t];if(!o||"object"!=typeof o){console.warn(`${F} dropped non-object binding at index ${t}`);continue}if(q(o)){n.push(o);continue}const i=V(o);null!==i&&n.push(i)}return n}function q(e){if(!e||"object"!=typeof e)return!1;const n=e;if("string"!=typeof n.id||0===n.id.length)return!1;if("event"!==n.type&&"init"!==n.type&&"data"!==n.type)return!1;const t=n.source;if(!t||"object"!=typeof t)return!1;if("string"!=typeof t.kind)return!1;const o=n.target;return!(!o||"object"!=typeof o)&&"string"==typeof o.kind}function V(e){if("string"!=typeof e.id||0===e.id.length)return console.warn(`${F} dropped binding with missing/invalid id`),null;const n=e.target;if(!n||"object"!=typeof n||"string"!=typeof n.instanceId||""===n.instanceId||"string"!=typeof n.method)return console.warn(`${F} dropped binding "${e.id}" missing/invalid target`),null;const t=e.type;let o;if("event"===t){const n=e.source;if(!n||"object"!=typeof n||"string"!=typeof n.instanceId||""===n.instanceId||"string"!=typeof n.event)return console.warn(`${F} dropped event binding "${e.id}" missing/invalid source`),null;o={kind:"instanceEvent",instanceId:n.instanceId,event:n.event}}else{if("init"!==t)return console.warn(`${F} dropped binding "${e.id}" with unknown legacy type "${String(e.type)}"`),null;{const n=e.source;n&&"string"==typeof n.instanceId&&""!==n.instanceId&&console.warn(`${F} init binding "${e.id}" had source.instanceId, discarded`),o={kind:"page",hook:"pageInit"}}}const i={kind:"instanceMethod",instanceId:n.instanceId,method:n.method};let a;a=void 0===n.args?{kind:"passthrough"}:Array.isArray(n.args)&&0===n.args.length?{kind:"static",args:[]}:Array.isArray(n.args)?{kind:"static",args:j(n.args)}:{kind:"passthrough"};const r={},s=e.options;s&&"object"==typeof s&&(!0===s.once&&(r.once=!0),"number"==typeof s.throttleMs&&(r.throttle={windowMs:s.throttleMs}),"number"==typeof s.debounceMs&&(r.debounce={windowMs:s.debounceMs}));const c=void 0!==r.once||void 0!==r.throttle||void 0!==r.debounce,d={id:e.id,source:o,target:i,mapping:a,...void 0!==e.disabled?{disabled:e.disabled}:{},...c?{schedule:r}:{}};return"event"===t?{...d,type:"event"}:{...d,type:"init"}}function K(e){const n=e.instances.map(X),t=_(e.componentOverrides,n),o=N(e.bindings);if("1"===e.schemaVersion){const i=ge(ee(e.layout)?e.layout:Z(e.layout));return{...e,layout:i,instances:n,bindings:o,componentOverrides:t}}return{schemaVersion:"1",layout:ge(Z(e.layout)),instances:n,bindings:o,componentOverrides:t}}function J(e){const n=function(e){var n;const t=new Map;for(const o of e){if(!o.parentId)continue;if(void 0!==o.slot)continue;const e=t.get(o.parentId),i=null==(n=o.layoutItem)?void 0:n.ratio;e?e.push(i):t.set(o.parentId,[i])}let o=!1;const i=e.map(e=>{if(!e.containerLayout||"split"!==e.containerLayout.mode)return e;const n=t.get(e.instanceId)??[],i=e.containerLayout.ratios,a=Q(i,n);return i.length===a.length&&i.every((e,n)=>e===a[n])?e:(o=!0,{...e,containerLayout:{...e.containerLayout,ratios:a}})});return o?i:e}(e.instances),t=e.layout.rootLayout?function(e,n){const t=e.rootLayout;if(!t||"split"!==t.mode)return e;const o=n.filter(e=>void 0===e.parentId).map(e=>{var n;return null==(n=e.layoutItem)?void 0:n.ratio}),i=t.ratios,a=Q(i,o);return i.length===a.length&&i.every((e,n)=>e===a[n])?e:{...e,rootLayout:{...t,ratios:a}}}(e.layout,n):e.layout;return n===e.instances&&t===e.layout?e:{...e,layout:t,instances:n}}function _(e,n){if(!e||"object"!=typeof e||Array.isArray(e))return{};const t=new Set(n.map(e=>e.instanceId)),o={};for(const[n,i]of Object.entries(e)){if(!i||"object"!=typeof i||Array.isArray(i))continue;const e=i;e.instanceId===n&&t.has(e.instanceId)&&"string"==typeof e.baseVersionKey&&e.baseVersionKey&&ce(e.source)&&de(e.contract)&&(o[n]={instanceId:e.instanceId,baseVersionKey:e.baseVersionKey,source:e.source,contract:e.contract,...le(e.contractParseError)?{contractParseError:le(e.contractParseError)}:{},..."string"==typeof e.createdAt?{createdAt:e.createdAt}:{},..."string"==typeof e.updatedAt?{updatedAt:e.updatedAt}:{}})}return o}function X(e){let n=e;void 0===n.parentId&&n.slotPlacement&&(n={...n,parentId:n.slotPlacement.parentInstanceId,slot:n.slotPlacement.slotName}),""!==n.slot&&"default"!==n.slot||(n={...n,slot:void 0}),void 0===n.placement&&(n={...n,placement:void 0===n.parentId?"absolute":"slot"});const t=U(n.sizing,n.size);if(t!==n.size&&(n={...n,size:t}),void 0!==n.containerLayout){const e=W(n.containerLayout);if(e!==n.containerLayout)if(null===e){const{containerLayout:e,...t}=n;n=t}else n={...n,containerLayout:e}}if(n=fe(n),n=he(n),void 0!==n.layoutItem){const e=Ie(n.layoutItem);if(null===e){const{layoutItem:e,...t}=n;n=t}else e!==n.layoutItem&&(n={...n,layoutItem:e})}if(!0===n.locked){const e={};void 0===n.lockPosition&&(e.lockPosition=!0),void 0===n.lockSize&&(e.lockSize=!0),Object.keys(e).length>0&&(n={...n,...e})}return n}const Y=new Set(["px","percent","fill","hug","auto"]);function U(e,n){var t,o,i,a;const r=n?function(e){const n={},t=G(e.width),o=G(e.height);return t&&(n.width=t),o&&(n.height=o),n.width||n.height?n:void 0}(n):void 0;if(!e)return r;const s={};if(e.width){const n=H(e.width,null==(t=e.min)?void 0:t.w,null==(o=e.max)?void 0:o.w);n&&(s.width=n)}if(e.height){const n=H(e.height,null==(i=e.min)?void 0:i.h,null==(a=e.max)?void 0:a.h);n&&(s.height=n)}return r?{width:r.width??s.width,height:r.height??s.height}:Object.keys(s).length>0?s:void 0}function H(e,n,t){if(!e||"object"!=typeof e)return null;let o;switch(e.mode){case"fixed":o="px";break;case"percent":o="percent";break;case"fill":o="fill";break;case"hug":o="hug";break;default:return null}const i={mode:o};return"px"!==o&&"percent"!==o||"number"!=typeof e.value||(i.value=e.value),"number"==typeof n&&(i.min=n),"number"==typeof t&&(i.max=t),i}function G(e){if(!e||"object"!=typeof e)return null;if("string"!=typeof e.mode)return null;if(!Y.has(e.mode))return null;const n={mode:e.mode};return"px"!==e.mode&&"percent"!==e.mode||"number"!=typeof e.value||(n.value=e.value),"number"==typeof e.min&&(n.min=e.min),"number"==typeof e.max&&(n.max=e.max),n}function W(e){if(!e||"object"!=typeof e)return null;if("none"===e.mode)return{mode:"none"};if("free"===e.mode)return{mode:"free"};if("flex"===e.mode){const n=e,t={mode:"flex",direction:"row"===n.direction||"column"===n.direction?n.direction:"row"};return!0===n.wrap&&(t.wrap=!0),"number"==typeof n.gap&&Number.isFinite(n.gap)&&n.gap>=0&&(t.gap=n.gap),"start"!==n.justify&&"center"!==n.justify&&"end"!==n.justify&&"space-between"!==n.justify&&"space-around"!==n.justify||(t.justify=n.justify),"start"!==n.align&&"center"!==n.align&&"end"!==n.align&&"stretch"!==n.align||(t.align=n.align),t}if("split"===e.mode){const n=e;if("horizontal"!==n.direction&&"vertical"!==n.direction)return null;if(!Array.isArray(n.ratios))return null;const t=n.ratios.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e>=0),o={mode:"split",direction:n.direction,ratios:t};return"number"==typeof n.gap&&Number.isFinite(n.gap)&&n.gap>=0&&(o.gap=n.gap),o}if("grid"===e.mode){const n=e;if(!Array.isArray(n.columns)||!Array.isArray(n.rows))return null;const t={mode:"grid",columns:n.columns.filter(e=>!!e&&("fr"===e.mode||"px"===e.mode||"percent"===e.mode)&&"number"==typeof e.value&&Number.isFinite(e.value)&&e.value>=0).slice(0,32),rows:n.rows.filter(e=>!!e&&("fr"===e.mode||"px"===e.mode||"percent"===e.mode||"auto"===e.mode)&&("auto"===e.mode&&void 0===e.value||"number"==typeof e.value&&Number.isFinite(e.value)&&e.value>=0)).slice(0,32)};if("number"==typeof n.gap&&Number.isFinite(n.gap)&&n.gap>=0)t.gap=n.gap;else if(n.gap&&"object"==typeof n.gap){const e={};"number"==typeof n.gap.row&&Number.isFinite(n.gap.row)&&n.gap.row>=0&&(e.row=n.gap.row),"number"==typeof n.gap.column&&Number.isFinite(n.gap.column)&&n.gap.column>=0&&(e.column=n.gap.column),Object.keys(e).length>0&&(t.gap=e)}if(n.cells&&"object"==typeof n.cells&&!Array.isArray(n.cells)){const e={};for(const[t,o]of Object.entries(n.cells)){if(!o||"object"!=typeof o)continue;if(!Number.isFinite(o.row)||!Number.isFinite(o.column))continue;const n={row:o.row,column:o.column};"number"==typeof o.rowSpan&&Number.isFinite(o.rowSpan)&&o.rowSpan>0&&o.rowSpan<=32&&(n.rowSpan=o.rowSpan),"number"==typeof o.columnSpan&&Number.isFinite(o.columnSpan)&&o.columnSpan>0&&o.columnSpan<=32&&(n.columnSpan=o.columnSpan),e[t]=n}Object.keys(e).length>0&&(t.cells=e)}return t}return null}function Q(e,n){const t=(e??[]).map(e=>"number"==typeof e&&Number.isFinite(e)&&e>=0?e:0),o=[];for(let e=0;e<n.length;e++){const i=n[e];if("number"==typeof i&&Number.isFinite(i)&&i>0){o.push(i);continue}const a=t[e];"number"==typeof a&&a>0?o.push(a):o.push(1)}return o}function Z(e){if(!e)return{type:"free",canvas:{width:{mode:"px",value:1920},height:{mode:"px",value:1080}}};if(ee(e))return e;const n=e,t={width:{mode:"px",value:n.canvas.w},height:{mode:"px",value:n.canvas.h}},o=function(e){if(!e)return;const n={};if(void 0!==e.color&&(n.color=e.color),void 0!==e.imageAssetId){const t={id:e.imageAssetId,type:"image"};n.image=t}return void 0!==e.fit&&(n.imageFit="original"===e.fit?"center":e.fit),Object.keys(n).length>0?n:void 0}(n.canvas.background),i={type:n.type,canvas:t};return o&&(i.background=o),void 0!==n.canvas.gridSize&&(i.guides={grid:{size:n.canvas.gridSize}}),i}function ee(e){if(!e)return!1;const n=e.canvas;if(!n)return!1;const t=n.width;return"object"==typeof t&&null!==t&&"mode"in t&&"string"==typeof t.mode}function ne(e,n=1920){return"px"===e.mode?e.value:n}function te(e,n,t=1920){switch(e.mode){case"px":return e.value;case"percent":return n>0?n*e.value/100:t;case"vw":return"undefined"!=typeof window?window.innerWidth*e.value/100:t;case"vh":return"undefined"!=typeof window?window.innerHeight*e.value/100:t;case"auto":case"fill":return n>0?n:t}}function oe(e,n,t,o){const i=ie(e.widthMode,e.width),a=ie(e.heightMode,e.height),r="free"===o,s={boxSizing:"border-box",minWidth:0,minHeight:0,overflow:e.overflow??"hidden",zIndex:n};return null!==i&&(s.width=i),null!==a&&(s.height=a),"number"==typeof t&&Number.isFinite(t)&&0!==t&&(s.transform=`rotate(${t}deg)`),r?(s.position="absolute",s.left=`${e.x}px`,s.top=`${e.y}px`):s.position="relative",s}function ie(e,n){switch(e){case"px":return`${n}px`;case"percent":return`${n}%`;case"fill":return"100%";case"auto":return"auto"}}function ae(e){if(!e||"none"===e.mode||"free"===e.mode)return null;if("flex"===e.mode){const n={display:"flex"};if(n.flexDirection=e.direction??"row",e.wrap&&(n.flexWrap="wrap"),"number"==typeof e.gap&&(n.gap=`${e.gap}px`),e.justify){const t={start:"flex-start",end:"flex-end",center:"center","space-between":"space-between","space-around":"space-around"};n.justifyContent=t[e.justify]??e.justify}if(e.align){const t={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch"};n.alignItems=t[e.align]??e.align}return n}if("grid"===e.mode){const n={display:"grid"},t=(e.columns??[]).map(e=>"fr"===e.mode?`${e.value}fr`:"px"===e.mode?`${e.value}px`:`${e.value}%`).join(" "),o=(e.rows??[]).map(e=>"auto"===e.mode?"auto":"fr"===e.mode?`${e.value??1}fr`:"px"===e.mode?`${e.value??0}px`:`${e.value??0}%`).join(" ");if(t&&(n.gridTemplateColumns=t),o&&(n.gridTemplateRows=o),"number"==typeof e.gap)n.gap=`${e.gap}px`;else if(e.gap&&"object"==typeof e.gap){const t=e.gap.row??0,o=e.gap.column??0;n.gap=`${t}px ${o}px`}return n}if("split"===e.mode){const n=(Array.isArray(e.ratios)?e.ratios:[]).map(e=>"number"==typeof e&&Number.isFinite(e)&&e>=0?e:0).filter(e=>e>0),t=n.length>0?n.map(e=>`${e}fr`).join(" "):"1fr",o={display:"grid"};return"vertical"===e.direction?o.gridTemplateRows=t:o.gridTemplateColumns=t,"number"==typeof e.gap&&(o.gap=`${e.gap}px`),o}return null}function re(e,n){if(!e)return null;if("flex"===n){const n={};return"number"==typeof e.order&&(n.order=e.order),"number"==typeof e.grow&&(n.flexGrow=e.grow),"number"==typeof e.shrink&&(n.flexShrink=e.shrink),Object.keys(n).length>0?n:null}if("grid"===n){const n={};if("number"==typeof e.row){const t="number"==typeof e.rowSpan&&e.rowSpan>0?e.rowSpan:1;n.gridRow=t>1?`${e.row} / span ${t}`:`${e.row}`}if("number"==typeof e.column){const t="number"==typeof e.columnSpan&&e.columnSpan>0?e.columnSpan:1;n.gridColumn=t>1?`${e.column} / span ${t}`:`${e.column}`}return Object.keys(n).length>0?n:null}return null}function se(e){switch(e.mode){case"px":return`${e.value}px`;case"percent":return`${e.value}%`;case"vw":return`${e.value}vw`;case"vh":return`${e.value}vh`;case"auto":return"auto";case"fill":return"100%"}}function ce(e){return!!e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.html&&"string"==typeof e.js&&"string"==typeof e.css}function de(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const n=e;return["propsDecl","emitsDecl","methodsDecl","slotsDecl","modelDecl","dataInputsDecl","dataOutputsDecl"].every(e=>Array.isArray(n[e]))}function le(e){if(!e||"object"!=typeof e||Array.isArray(e))return;const n=e;return"string"==typeof n.message?{message:n.message,..."number"==typeof n.line?{line:n.line}:{},..."number"==typeof n.column?{column:n.column}:{}}:void 0}const ue=new Set(["px","percent","fill","auto"]),pe=new Set(["hidden","visible","auto"]);function fe(e){const n=e.placement;return"canvas"===n||"container"===n?e:"absolute"===n?{...e,placement:"canvas"}:"slot"===n?{...e,placement:"container"}:{...e,placement:e.parentId?"container":"canvas"}}function he(e){var n,t;const o=e.rect??{x:0,y:0,w:0,h:0},i=null==(n=e.size)?void 0:n.width,a=null==(t=e.size)?void 0:t.height,r=e=>{if(e)return"hug"===e.mode?"auto":"percent"===e.mode?"percent":"fill"===e.mode?"fill":"auto"===e.mode?"auto":"px"===e.mode?"px":void 0},s=e.layoutBox,c=s&&ue.has(s.widthMode)?s.widthMode:r(i)??"px",d=s&&ue.has(s.heightMode)?s.heightMode:r(a)??"px",l=(e,n)=>"number"==typeof e&&Number.isFinite(e)?e:n,u={x:l(null==s?void 0:s.x,o.x),y:l(null==s?void 0:s.y,o.y),width:l(null==s?void 0:s.width,(null==i?void 0:i.value)??o.w),height:l(null==s?void 0:s.height,(null==a?void 0:a.value)??o.h),widthMode:c,heightMode:d,overflow:(null==s?void 0:s.overflow)&&pe.has(s.overflow)?s.overflow:"hidden"};return s&&s.x===u.x&&s.y===u.y&&s.width===u.width&&s.height===u.height&&s.widthMode===u.widthMode&&s.heightMode===u.heightMode&&s.overflow===u.overflow?e:{...e,layoutBox:u}}function ge(e){if(e.rootLayout){const o=W(e.rootLayout);return null===o?{...e,rootLayout:{mode:"free"}}:(t=o,(n=e.rootLayout).mode===t.mode&&JSON.stringify(n)===JSON.stringify(t)?e:{...e,rootLayout:o})}var n,t;return{...e,rootLayout:{mode:"free"}}}function ve(e){return"container"===e||"slot"===e}function ye(e,n,t){var o,i;const a=n.find(e=>e.instanceId===t);if(!a)return;if(void 0===a.parentId)return(null==(o=null==e?void 0:e.rootLayout)?void 0:o.mode)??"free";const r=n.find(e=>e.instanceId===a.parentId);return(null==(i=null==r?void 0:r.containerLayout)?void 0:i.mode)??"none"}function me(e){return"canvas"===e||"absolute"===e||void 0===e}function Ie(e){if(!e||"object"!=typeof e)return null;const n={},t=["order","grow","shrink","row","column","rowSpan","columnSpan","ratio"];for(const o of t){const t=e[o];"number"==typeof t&&Number.isFinite(t)&&(n[o]=t)}return Object.keys(n).length>0?n:null}function we(n={}){const{rootMargin:t="500px",disposeDelayMs:o=1500,mountConcurrency:i=2,root:a=null}=n,r={state:e({}),elById:new Map,idByEl:new WeakMap,mountQueue:[],disposeTimers:new Map,idleScheduled:!1,io:null};function s(e){for(const n of e){const e=r.idByEl.get(n.target);e&&(n.isIntersecting?c(e):d(e))}}function c(e){const n=r.disposeTimers.get(e);n&&(clearTimeout(n),r.disposeTimers.delete(e));const t=r.state[e];"mounted"!==t&&"disposing"!==t?(r.state[e]="mounting",r.mountQueue.includes(e)||r.mountQueue.push(e),l()):r.state[e]="mounted"}function d(e){const n=r.state[e];if("pending"===n||"idle"===n)return;if("mounting"===n){const n=r.mountQueue.indexOf(e);return n>=0&&r.mountQueue.splice(n,1),void(r.state[e]="pending")}r.state[e]="disposing";const t=r.disposeTimers.get(e);t&&clearTimeout(t);const i=setTimeout(()=>{"disposing"===r.state[e]&&(r.state[e]="pending",r.disposeTimers.delete(e))},o);r.disposeTimers.set(e,i)}function l(){r.idleScheduled||0===r.mountQueue.length||(r.idleScheduled=!0,function(e,n=50){const t=globalThis;"function"==typeof t.requestIdleCallback?t.requestIdleCallback(()=>e(),{timeout:n}):setTimeout(e,16)}(()=>{r.idleScheduled=!1;let e=0;for(;e<i&&r.mountQueue.length>0;){const n=r.mountQueue.shift();"mounting"===r.state[n]&&(r.state[n]="mounted",e++)}r.mountQueue.length>0&&l()}))}return{register(e,n){const o=r.elById.get(e);if(o&&o!==n){const e=r.io;e&&e.unobserve(o),r.idByEl.delete(o)}r.elById.set(e,n),r.idByEl.set(n,e),r.state[e]="pending";const i=r.io?r.io:"undefined"==typeof IntersectionObserver?null:(r.io=new IntersectionObserver(s,{root:a,rootMargin:t}),r.io);i?i.observe(n):r.state[e]="mounted"},unregister(e){const n=r.elById.get(e);if(n){const t=r.io;t&&t.unobserve(n),r.idByEl.delete(n),r.elById.delete(e)}const t=r.disposeTimers.get(e);t&&(clearTimeout(t),r.disposeTimers.delete(e));const o=r.mountQueue.indexOf(e);o>=0&&r.mountQueue.splice(o,1),delete r.state[e]},isMounted(e){const n=r.state[e];return"mounted"===n||"disposing"===n},getState:e=>r.state[e]??"idle",get state(){return r.state},dispose(){r.io&&(r.io.disconnect(),r.io=null);for(const e of r.disposeTimers.values())clearTimeout(e);r.disposeTimers.clear(),r.elById.clear(),r.mountQueue.length=0;for(const e of Object.keys(r.state))delete r.state[e]}}}function xe(e){const n=[];switch(e.source.kind){case"instanceEvent":case"lifecycle":n.push({canvasId:e.source.canvasId,instanceId:e.source.instanceId});break;case"page":case"dataSource":break;default:ke(e.source)}switch(e.target.kind){case"instanceMethod":case"instanceEmit":case"instanceDataInput":n.push({canvasId:e.target.canvasId,instanceId:e.target.instanceId});break;default:Se(e.target)}return n}function be(e,n,t){for(const o of xe(e))if(o.instanceId===n&&o.canvasId===t)return!0;return!1}function ke(e){throw new Error(`[hc-canvas/bindingRefs] Unhandled BindingSource.kind: ${e.kind}`)}function Se(e){throw new Error(`[hc-canvas/bindingRefs] Unhandled BindingTarget.kind: ${e.kind}`)}function Me(e){const n={type:e.type,canvas:{...e.canvas,width:{...e.canvas.width},height:{...e.canvas.height}}};return e.background&&(n.background={...e.background,...e.background.image?{image:{...e.background.image}}:{}}),e.behavior&&(n.behavior={...e.behavior}),e.guides&&(n.guides={...e.guides,...e.guides.items?{items:[...e.guides.items]}:{}}),e.rootLayout&&(n.rootLayout="grid"===(t=e.rootLayout).mode?{...t,columns:t.columns?t.columns.map(e=>({...e})):[],rows:t.rows?t.rows.map(e=>({...e})):[],...t.cells?{cells:{...t.cells}}:{},..."object"==typeof t.gap&&null!==t.gap?{gap:{...t.gap}}:{}}:"split"===t.mode?{...t,ratios:Array.isArray(t.ratios)?[...t.ratios]:[]}:{...t}),n;var t}function Te(e={}){return JSON.parse(JSON.stringify(e))}function ze(){return{schemaVersion:"1",layout:{type:"free",canvas:{width:{mode:"fill"},height:{mode:"fill"}}},instances:[],bindings:[]}}function Be(t={schemaVersion:"1",layout:{type:"free",canvas:{width:{mode:"fill"},height:{mode:"fill"}}},instances:[],bindings:[]}){const o=K(t),i=e({schemaVersion:"1",layout:Me(o.layout),instances:o.instances.map(e=>({...e,rect:{...e.rect}})),bindings:o.bindings.map(e=>j(e)),componentOverrides:Te(o.componentOverrides)});function a(e){return i.instances.findIndex(n=>n.instanceId===e)}function r(e){return i.bindings.findIndex(n=>n.id===e)}return{get document(){return i},instanceCount:n(()=>i.instances.length),bindingCount:n(()=>i.bindings.length),addInstance(e){if(a(e.instanceId)>=0)return void console.warn(`[hc-canvas/doc-store] instanceId "${e.instanceId}" 已存在,addInstance 忽略`);const n=e.rect?{...e.rect}:function(e){if(!e)return{x:0,y:0,w:0,h:0};const n=(e,n)=>"number"==typeof e&&Number.isFinite(e)?e:n;return{x:n(e.x,0),y:n(e.y,0),w:n(e.width,0),h:n(e.height,0)}}(e.layoutBox),t={...e,rect:n};!0===t.locked&&(void 0===t.lockPosition&&(t.lockPosition=!0),void 0===t.lockSize&&(t.lockSize=!0)),i.instances.push(t)},removeInstance(e){var n;const t=a(e);t<0||(i.instances.splice(t,1),null==(n=i.componentOverrides)||delete n[e],i.bindings=i.bindings.filter(n=>!be(n,e)))},updateInstance(e,n){const t=i.instances.find(n=>n.instanceId===e);if(t&&(Object.assign(t,n),n.rect&&t.layoutBox&&(t.layoutBox={...t.layoutBox,x:t.rect.x,y:t.rect.y,..."px"===t.layoutBox.widthMode?{width:t.rect.w}:{},..."px"===t.layoutBox.heightMode?{height:t.rect.h}:{}}),n.layoutBox)){const e=t.layoutBox??n.layoutBox,o=e=>"number"==typeof e&&Number.isFinite(e);t.rect={x:o(e.x)?e.x:t.rect.x,y:o(e.y)?e.y:t.rect.y,w:"px"===e.widthMode&&o(e.width)?e.width:t.rect.w,h:"px"===e.heightMode&&o(e.height)?e.height:t.rect.h}}},moveInstance(e,n,t){const o=i.instances.find(n=>n.instanceId===e);o&&(o.rect.x=n,o.rect.y=t,o.layoutBox&&(o.layoutBox={...o.layoutBox,x:n,y:t}))},resizeInstance(e,n,t){const o=i.instances.find(n=>n.instanceId===e);if(!o)return;const a=Math.max(1,n),r=Math.max(1,t);o.rect.w=a,o.rect.h=r,o.layoutBox&&(o.layoutBox={...o.layoutBox,width:a,height:r,widthMode:"px",heightMode:"px"})},setInstanceProp(e,n,t){const o=i.instances.find(n=>n.instanceId===e);o&&(o.props={...o.props,[n]:t})},setInstanceLocked(e,n){const t=i.instances.find(n=>n.instanceId===e);t&&(t.locked=n,n?(t.lockPosition=!0,t.lockSize=!0):(delete t.lockPosition,delete t.lockSize))},setInstanceSize(e,n){const t=i.instances.find(n=>n.instanceId===e);if(t)if(null===n)delete t.size,t.layoutBox&&(t.layoutBox={...t.layoutBox,width:t.rect.w,height:t.rect.h,widthMode:"px",heightMode:"px"});else if(t.size=n,t.layoutBox){const e=n.width,o=n.height,i={...t.layoutBox};e&&("px"===e.mode?(i.widthMode="px","number"==typeof e.value&&Number.isFinite(e.value)&&(i.width=e.value)):"percent"===e.mode?(i.widthMode="percent","number"==typeof e.value&&Number.isFinite(e.value)&&(i.width=e.value)):"fill"===e.mode?(i.widthMode="fill",Number.isFinite(i.width)||(i.width=t.rect.w)):"auto"!==e.mode&&"hug"!==e.mode||(i.widthMode="auto",Number.isFinite(i.width)||(i.width=t.rect.w))),o&&("px"===o.mode?(i.heightMode="px","number"==typeof o.value&&Number.isFinite(o.value)&&(i.height=o.value)):"percent"===o.mode?(i.heightMode="percent","number"==typeof o.value&&Number.isFinite(o.value)&&(i.height=o.value)):"fill"===o.mode?(i.heightMode="fill",Number.isFinite(i.height)||(i.height=t.rect.h)):"auto"!==o.mode&&"hug"!==o.mode||(i.heightMode="auto",Number.isFinite(i.height)||(i.height=t.rect.h))),t.layoutBox=i}},setInstanceContainerLayout(e,n){const t=i.instances.find(n=>n.instanceId===e);t&&(null===n?delete t.containerLayout:t.containerLayout=n)},updateInstanceLayoutBox(e,n){const t=i.instances.find(n=>n.instanceId===e);if(!t)return;const o=t.layoutBox??{x:t.rect.x,y:t.rect.y,width:t.rect.w,height:t.rect.h,widthMode:"px",heightMode:"px",overflow:"hidden"},a={},r=["x","y","width","height"];for(const e of r){const t=n[e];"number"==typeof t&&Number.isFinite(t)&&(a[e]=t)}if("px"!==n.widthMode&&"percent"!==n.widthMode&&"fill"!==n.widthMode&&"auto"!==n.widthMode||(a.widthMode=n.widthMode),"px"!==n.heightMode&&"percent"!==n.heightMode&&"fill"!==n.heightMode&&"auto"!==n.heightMode||(a.heightMode=n.heightMode),"hidden"!==n.overflow&&"visible"!==n.overflow&&"auto"!==n.overflow||(a.overflow=n.overflow),0===Object.keys(a).length)return;const s={...o,...a};t.layoutBox=s;const c=a.widthMode??o.widthMode,d=a.heightMode??o.heightMode;t.rect={x:s.x,y:s.y,w:"px"===c?s.width:t.rect.w,h:"px"===d?s.height:t.rect.h}},updateInstanceLayoutItem(e,n){const t=i.instances.find(n=>n.instanceId===e);if(!t)return;if(null===n)return void delete t.layoutItem;const o=["order","grow","shrink","row","column","rowSpan","columnSpan","ratio"],a={};for(const e of o){const t=n[e];"number"==typeof t&&Number.isFinite(t)&&(a[e]=t)}if(0===Object.keys(a).length)return;const r=t.layoutItem??{};t.layoutItem={...r,...a}},setInstanceRotation(e,n){const t=i.instances.find(n=>n.instanceId===e);t&&Number.isFinite(n)&&(0===n?delete t.rotation:t.rotation=n)},duplicateInstance(e,n,t){var o;const a=i.instances.find(n=>n.instanceId===e);if(!a)return;const r=JSON.parse(JSON.stringify(a));if(r.instanceId=n,r.rect={...r.rect,x:a.rect.x+t.x,y:a.rect.y+t.y},r.layoutBox&&(r.layoutBox={...r.layoutBox,x:r.layoutBox.x+t.x,y:r.layoutBox.y+t.y}),delete r.locked,delete r.lockPosition,delete r.lockSize,i.instances.some(e=>e.instanceId===n))return void console.warn(`[hc-canvas/doc-store] duplicateInstance: newInstanceId "${n}" 已存在,忽略`);i.instances.push(r);const s=null==(o=i.componentOverrides)?void 0:o[e];s&&(i.componentOverrides={...i.componentOverrides??{},[n]:{...JSON.parse(JSON.stringify(s)),instanceId:n}})},addBinding(e){if(r(e.id)>=0)return void console.warn(`[hc-canvas/doc-store] binding id "${e.id}" 已存在,addBinding 忽略`);const[n]=N([e]);n?i.bindings.push(j(n)):console.warn(`[hc-canvas/doc-store] addBinding "${null==e?void 0:e.id}" dropped by normalize`)},removeBinding(e){const n=r(e);n<0||i.bindings.splice(n,1)},updateBinding(e,n){const t=i.bindings.find(n=>n.id===e);if(!t)return;const o=j(n);Object.assign(t,o)},updateLayout(e){for(const n of Object.keys(e)){const t=e[n];void 0===t?delete i.layout[n]:i.layout[n]=t}},setComponentOverride(e,n){null!==n?(i.componentOverrides||(i.componentOverrides={}),i.componentOverrides[e]=n):i.componentOverrides&&e in i.componentOverrides&&delete i.componentOverrides[e]},replaceDocument(e){const n=K(e);i.schemaVersion="1",i.layout=Me(n.layout),i.instances=n.instances.map(e=>({...e,rect:{...e.rect}})),i.bindings=n.bindings.map(e=>j(e)),i.componentOverrides=Te(n.componentOverrides)},getInstance:e=>i.instances.find(n=>n.instanceId===e),listInstancesByComponentVersionKey:e=>i.instances.filter(n=>n.componentVersionKey===e)}}function Le(){const t=e({ids:[]});return{selectedIds:n(()=>t.ids),size:n(()=>t.ids.length),primaryId:n(()=>t.ids[0]),select(e){t.ids=[e]},toggleSelect(e){const n=t.ids.indexOf(e);n>=0?t.ids.splice(n,1):t.ids.push(e)},addToSelection(e){t.ids.includes(e)||t.ids.push(e)},removeFromSelection(e){const n=t.ids.indexOf(e);n>=0&&t.ids.splice(n,1)},clearSelection(){t.ids=[]},selectAll(e){t.ids=Array.from(new Set(e))},purgeOrphans(e){const n=new Set(e);t.ids=t.ids.filter(e=>n.has(e))},isSelected:e=>t.ids.includes(e)}}function Pe(t={}){const{minScale:o=.25,maxScale:i=4,initialScale:a=1}=t,r=e({scale:a,panX:0,panY:0});function s(e){return Math.max(o,Math.min(i,e))}return{state:r,scale:n(()=>r.scale),panX:n(()=>r.panX),panY:n(()=>r.panY),setScale(e){r.scale=s(e)},zoomAt(e,n){const t=r.scale,o=s(t+n);if(o===t)return;const i=o/t;r.panX=e.x-(e.x-r.panX)*i,r.panY=e.y-(e.y-r.panY)*i,r.scale=o},setPan(e,n){r.panX=e,r.panY=n},panBy(e,n){r.panX+=e,r.panY+=n},resetView(){r.scale=a,r.panX=0,r.panY=0},fitToScreen(e,n,t=40){const o=Math.max(1,n.w-2*t),i=Math.max(1,n.h-2*t),a=o/e.w,c=i/e.h,d=s(Math.min(a,c)),l=e.w*d,u=e.h*d;r.scale=d,r.panX=(n.w-l)/2,r.panY=(n.h-u)/2},toCanvasPoint:e=>({x:(e.x-r.panX)/r.scale,y:(e.y-r.panY)/r.scale}),toViewportPoint:e=>({x:e.x*r.scale+r.panX,y:e.y*r.scale+r.panY})}}function Ce(e){const n=new Map;return{resolve(t){const o=function(e){return e.id||e.url||""}(t);if(o&&n.has(o))return n.get(o);if(!e){const e=t.url??"";return o&&n.set(o,e),e}const i=e.resolve(t);return"string"==typeof i?(o&&n.set(o,i),i):(o&&n.set(o,i),i.then(e=>{o&&n.set(o,e)},e=>{console.warn(`[hc-canvas/assets] resolve("${o}") 失败,缓存里删条目允许重试:`,e),o&&n.delete(o)}),i)},__clearCache(){n.clear()}}}function $e(e){const n=new Map,t=new Map,o=new Map,i=new Map,a=new Map,r=new Map;let s=!1,c=!1,d=0,l=null;function u(e){if(!c&&null!==l)try{l(e)}catch(e){console.error("[hc-canvas/dataStore] trace bridge listener threw",e)}}function p(e,n){var t;const a=o.get(e);if(a)for(const e of a)null==(t=i.get(e))||t.onUpdate(n)}function f(e,t){let o=n.get(e);return o||(o={cacheKey:e,sourceId:t,status:"idle"},n.set(e,o)),o}function h(t,r,s){if(!e)return;const l=a.get(t);l&&l.abort();const h=new AbortController;a.set(t,h);const g=f(t,r);g.status="loading";const v=g.writeSeq??0;Promise.resolve().then(()=>async function(e,n){return{value:await Promise.resolve(e.query(n))}}(e,{sourceId:r,params:s,signal:h.signal})).then(e=>{if(c)return;if(a.get(t)!==h)return;a.delete(t);const o=n.get(t);o&&((o.writeSeq??0)>v?u({kind:"data-query-skipped",cacheKey:t,sourceId:r,writeSeq:o.writeSeq,reason:"race-stale"}):(o.status="success",o.value=e.value,o.error=void 0,o.lastFetchedAt=Date.now(),o.writeSeq=++d,u({kind:"data-source-update",cacheKey:t,sourceId:r,writeSeq:o.writeSeq,value:e.value}),p(t,e.value)))}).catch(e=>{if(c)return;if(function(e){if(null===e||"object"!=typeof e)return!1;return"AbortError"===e.name}(e))return;if(a.get(t)!==h)return;a.delete(t);const s=n.get(t);s&&((s.writeSeq??0)>v?u({kind:"data-query-skipped",cacheKey:t,sourceId:r,writeSeq:s.writeSeq,reason:"race-stale-reject"}):(s.status="error",s.error=e,s.lastFetchedAt=Date.now(),function(e,n){var t,a;const r=o.get(e);if(r)for(const e of r)null==(a=null==(t=i.get(e))?void 0:t.onError)||a.call(t,n)}(t,e)))})}function g(e){if(c)return;const{bindingId:d,sourceId:l,params:u,onUpdate:p,onError:f}=e,g=function(e,n,t){if(!n||0===Object.keys(n).length)return`${e}::{}`;const o=Ee(n,t);return null===o?`${e}::__fresh_${Date.now()}_${Math.random().toString(36).slice(2,8)}__`:`${e}::${o}`}(l,u,()=>{s||(console.warn(`[hc-canvas/dataStore] params for "${l}" contains non-plain values; fresh query every call (no cache)`),s=!0)});!function(e,i){const s=t.get(e);if(s===i)return;if(s){const t=o.get(s);if(t&&(t.delete(e),0===t.size)){o.delete(s);const e=a.get(s);e&&(e.abort(),a.delete(s)),n.delete(s)}const i=r.get(e);if(i){try{i()}catch{}r.delete(e)}}t.set(e,i);let c=o.get(i);c||(c=new Set,o.set(i,c)),c.add(e)}(d,g),i.set(d,{onUpdate:p,onError:f});const v=n.get(g);if(v){if("success"===v.status)return void p(v.value);if("error"===v.status)return void(null==f||f(v.error));if("loading"===v.status)return}h(g,l,u)}return{request:g,subscribe:function(n){if(c)return;const{bindingId:o,sourceId:i,params:a,onUpdate:s,onError:l}=n;if(g({bindingId:o,sourceId:i,params:a,onUpdate:s,onError:l}),!e)return;const h=t.get(o);if(!h)return;let v=!0;try{const n=function(e,n){if(e.subscribe)return e.subscribe(n,e=>{if(c)return;if(!v)return;if(t.get(o)!==h)return;const n=f(h,i);n.status="success",n.value=e,n.lastFetchedAt=Date.now(),n.writeSeq=++d,u({kind:"data-source-update",cacheKey:h,sourceId:i,writeSeq:n.writeSeq,value:e}),p(h,e)})}(e,{sourceId:i,params:a});n?r.set(o,()=>{v=!1;try{n()}catch{}}):r.set(o,()=>{v=!1})}catch(e){v=!1,c||null==l||l(e)}},removeBinding:function(e,s){if(c)return;const d=!0===(null==s?void 0:s.preserveCache),l=r.get(e);if(l){try{l()}catch{}r.delete(e)}i.delete(e);const u=function(e){const n=t.get(e);if(!n)return;t.delete(e);const i=o.get(n);return i&&(i.delete(e),0===i.size&&o.delete(n)),n}(e);if(u&&!o.has(u)){const e=n.get(u);if(!d||"success"!==(null==e?void 0:e.status)){const e=a.get(u);e&&(e.abort(),a.delete(u)),n.delete(u)}}},invalidate:function(e){if(c)return;const t=[];for(const[o,i]of n)void 0!==e&&i.sourceId!==e||t.push(o);for(const e of t){const t=n.get(e);if(!t)continue;const i=o.get(e);if(!i||0===i.size){n.delete(e);const t=a.get(e);t&&(t.abort(),a.delete(e));continue}t.status="stale",h(e,t.sourceId,void 0)}},getSnapshot:function(){return{entries:Array.from(n.values()).map(e=>({cacheKey:e.cacheKey,sourceId:e.sourceId,status:e.status,value:e.value,error:e.error,lastFetchedAt:e.lastFetchedAt}))}},disposeAll:function(){if(!c){c=!0;for(const e of a.values())try{e.abort()}catch{}a.clear();for(const e of r.values())try{e()}catch{}r.clear(),n.clear(),t.clear(),o.clear(),i.clear(),l=null}},attachTraceBridge:function(e){return c?()=>{}:(l=e,()=>{l===e&&(l=null)})},getBindingsForCacheKey:function(e){const n=o.get(e);return n?Array.from(n):[]},get isDisposed(){return c}}}function Ee(e,n,t=new WeakSet){if(null==e)return JSON.stringify(e);const o=typeof e;if("string"===o||"number"===o||"boolean"===o)return JSON.stringify(e);if("function"===o||"symbol"===o||"bigint"===o)return null==n||n(),null;if(Array.isArray(e)){if(t.has(e))return null==n||n(),null;t.add(e);const o=[];for(const i of e){const e=Ee(i,n,t);if(null===e)return null;o.push(e)}return`[${o.join(",")}]`}if("object"===o){const o=Object.getPrototypeOf(e);if(o!==Object.prototype&&null!==o)return null==n||n(),null;const i=e;if(t.has(i))return null==n||n(),null;t.add(i);const a=Object.keys(i).sort(),r=[];for(const e of a){const o=Ee(i[e],n,t);if(null===o)return null;r.push(`${JSON.stringify(e)}:${o}`)}return`{${r.join(",")}}`}return null==n||n(),null}const Oe=Symbol("hc:canvas:context");function De(e={}){var t,a;const r=Be(e.initialDocument),s=Le(),c=Pe(e.viewport),d=we(e.scheduler),l=$e(null==(t=e.adapters)?void 0:t.data);let u=!1;const p=[];e.hooks&&p.push(e.hooks);const f=o(!1),h=n(()=>f.value),g=o({}),v=n(()=>g.value),y=n(()=>{var n;const t=(null==(n=e.getMode)?void 0:n.call(e))??"design",o=function(e){switch(e){case"design":return{selectable:!0,draggable:!0,resizable:!0,keyboardMove:!0,snap:!0,grid:!1,allowOverflow:!0,locked:!1};case"preview":case"runtime":return{selectable:!1,draggable:!1,resizable:!1,keyboardMove:!1,snap:!0,grid:!1,allowOverflow:!0,locked:!1};case"inspect":return{selectable:!0,draggable:!1,resizable:!1,keyboardMove:!1,snap:!0,grid:!1,allowOverflow:!0,locked:!1}}}(t),i=r.document.layout.behavior??{};if("design"!==t){const{selectable:e,draggable:n,resizable:t,keyboardMove:a,...r}=i;return{...o,...r,...g.value}}return{...o,...i,...g.value}}),m=Ce(null==(a=e.adapters)?void 0:a.assets),I=o("select"),w=o(null),x=n(()=>w.value??I.value),b=o(null),k=n(()=>b.value),S=o(null),M=o({w:0,h:0}),T=n(()=>M.value),z=n(()=>{const e=r.document.layout,n=M.value;return{w:te(e.canvas.width,n.w,1920),h:te(e.canvas.height,n.h,1080)}}),B=o([]),L=n(()=>B.value),P=o(0),C=n(()=>P.value>0);return{document:r,selection:s,viewport:c,scheduler:d,adapters:e.adapters??{},dataStore:l,dispatch:function(e){var n,t;if(u)console.warn("[hc-canvas/context] dispatch called after dispose()");else{for(const t of p)if(!1===(null==(n=t.onBeforeAction)?void 0:n.call(t,e)))return;switch(e.type){case"addInstance":r.addInstance(e.payload.instance);break;case"removeInstance":r.removeInstance(e.payload.instanceId),s.removeFromSelection(e.payload.instanceId);break;case"updateInstance":r.updateInstance(e.payload.instanceId,e.payload.patch);break;case"moveInstance":r.moveInstance(e.payload.instanceId,e.payload.x,e.payload.y);break;case"resizeInstance":r.resizeInstance(e.payload.instanceId,e.payload.w,e.payload.h);break;case"setInstanceProp":r.setInstanceProp(e.payload.instanceId,e.payload.key,e.payload.value);break;case"addBinding":r.addBinding(e.payload.binding);break;case"removeBinding":r.removeBinding(e.payload.bindingId);break;case"updateBinding":r.updateBinding(e.payload.bindingId,e.payload.patch);break;case"updateLayout":r.updateLayout(e.payload.patch);break;case"setRootLayout":{const{rootLayout:n}=e.payload;r.updateLayout({rootLayout:null===n?void 0:n});break}case"replaceDocument":r.replaceDocument(e.payload.document),s.purgeOrphans(r.document.instances.map(e=>e.instanceId));break;case"setComponentOverride":{const{instanceId:n,override:t}=e.payload;if(void 0===r.getInstance(n)){console.warn(`[hc-canvas/context] setComponentOverride: instance "${n}" 不存在,no-op`);break}r.setComponentOverride(n,t);break}case"setInstanceLocked":r.setInstanceLocked(e.payload.instanceId,e.payload.locked);break;case"duplicateInstance":r.duplicateInstance(e.payload.instanceId,e.payload.newInstanceId,e.payload.offset??{x:20,y:20});break;case"setInstanceSize":{const{instanceId:n,size:t}=e.payload;if(null===t)r.setInstanceSize(n,null);else{const e=U(void 0,t);r.setInstanceSize(n,e??null)}break}case"setContainerLayout":{const{instanceId:n,containerLayout:t}=e.payload;if(null===t)r.setInstanceContainerLayout(n,null);else{const e=W(t);null!==e&&r.setInstanceContainerLayout(n,e)}break}case"updateLayoutBox":r.updateInstanceLayoutBox(e.payload.instanceId,e.payload.patch);break;case"updateLayoutItem":r.updateInstanceLayoutItem(e.payload.instanceId,e.payload.patch);break;case"updateRotation":r.setInstanceRotation(e.payload.instanceId,e.payload.value);break;case"select":s.select(e.payload.instanceId);break;case"toggleSelect":s.toggleSelect(e.payload.instanceId);break;case"addToSelection":s.addToSelection(e.payload.instanceId);break;case"removeFromSelection":s.removeFromSelection(e.payload.instanceId);break;case"clearSelection":s.clearSelection();break;case"selectAll":s.selectAll(e.payload.instanceIds);break;default:{const n=e;console.warn("[hc-canvas/context] unknown action",n)}}for(const n of p)null==(t=n.onAfterAction)||t.call(n,e)}},dispose:function(){u||(u=!0,f.value=!1,d.dispose(),l.disposeAll())},isBatching:h,beginBatch:function(){u||f.value||(f.value=!0)},endBatch:function(e){var n;if(!u&&f.value){for(const t of p)null==(n=t.onAfterBatch)||n.call(t,e);f.value=!1}},registerHooks:function(e){return p.push(e),()=>{const n=p.indexOf(e);n>=0&&p.splice(n,1)}},isRecordingSuppressed:C,suppressRecording:function(e){P.value++;try{return e()}finally{P.value--}},effectiveBehavior:y,interactionOptions:v,setInteractionOptions:function(e){const n={...g.value};for(const t of Object.keys(e)){const o=e[t];void 0===o?delete n[t]:n[t]=o}g.value=n},resolveAsset:function(e){return m.resolve(e)},toolMode:x,setToolMode:function(e){I.value=e},setTemporaryToolMode:function(e){w.value=e},mouseCanvasPoint:k,setMouseCanvasPoint:function(e){b.value=e},measuredStageSize:T,measuredCanvasSize:z,setMeasuredStageSize:function(e){const n=Math.max(0,Math.round(e.w)),t=Math.max(0,Math.round(e.h));M.value.w===n&&M.value.h===t||(M.value={w:n,h:t})},layoutIssues:L,setLayoutIssues:function(e){B.value=e},cannotDragLayoutManagedChildEvent:i(S),setCannotDragLayoutManagedChildEvent:function(e){S.value=e}}}function Re(e){a(Oe,e)}function Ae(){const e=t(Oe);if(!e)throw new Error("[hc-canvas] useCanvasContext() called outside <CanvasProvider> / <HyperCardCanvasDesigner>. Make sure the component tree is wrapped by a provider.");return e}const je="default",Fe=8;function Ne(e){return e.slot??je}function qe(e,n){const t=[],o=n.resolveContract,i=n.maxDepth??8,a=new Map;for(const n of e.instances)a.set(n.instanceId,n);for(const n of e.instances){if(void 0===n.parentId&&void 0!==n.slot&&n.slot!==je){Ve(t,"orphan-slot",n.instanceId,`slot "${n.slot}" 没有 parentId,数据不完整`);continue}if(void 0===n.parentId)continue;if(!a.has(n.parentId)){Ve(t,"missing-parent",n.instanceId,`parentId "${n.parentId}" 指向不存在的实例`);continue}"absolute"!==n.placement&&"canvas"!==n.placement||Ve(t,"absolute-child-rejected",n.instanceId,"parentId + placement='absolute'|'canvas' 在 D4.5f MVP 不支持,只允许 root absolute/canvas 或 child slot/container");const e=a.get(n.parentId),i=o(e.componentVersionKey);if(!i)continue;const r=i.slotsDecl??[];if(0===r.length){Ve(t,"parent-not-layout",n.instanceId,`父组件 "${e.componentId}" 不是布局组件(slotsDecl 为空)`);continue}const s=Ne(n),c=Ke(r,s);c?c.accepts&&c.accepts.length>0&&(c.accepts.includes(n.componentId)||Ve(t,"slot-not-allowed-component",n.instanceId,`slot "${s}" 不允许 componentId "${n.componentId}"(accepts: ${c.accepts.join(", ")})`)):Ve(t,"invalid-slot",n.instanceId,`slot "${s}" 不在父 "${e.componentId}" 的 slotsDecl 中(可能组件升级删除了该 slot)`)}const r=new Map;for(const n of e.instances){if(void 0===n.parentId)continue;const e=Ne(n),t=`${n.parentId}::${e}`;let o=r.get(t);o||(o=[],r.set(t,o)),o.push(n)}for(const[e,n]of r){if(n.length<=1)continue;const[i,r]=Je(e),s=a.get(i);if(!s)continue;const c=o(s.componentVersionKey);if(!c)continue;const d=Ke(c.slotsDecl??[],r);if(d&&!0!==d.multiple)for(let e=1;e<n.length;e++)Ve(t,"slot-multiple-violated",n[e].instanceId,`slot "${r}" 不允许多个子实例(SlotDecl.multiple !== true)`)}const s=new Map;for(const n of e.instances)s.set(n.instanceId,0);for(const n of e.instances)0===s.get(n.instanceId)&&c(n.instanceId,[],0);function c(e,n,o){s.set(e,1);const r=a.get(e);if(o>i)return Ve(t,"depth-exceeded",e,`嵌套深度 ${o} 超过上限 ${i}`),void s.set(e,2);const d=r.parentId;if(void 0===d)return void s.set(e,2);if(!a.has(d))return void s.set(e,2);const l=s.get(d);if(1===l)return Ve(t,"cycle",e,`parentId 链成环:${[...n,e,d].join(" → ")}`),void s.set(e,2);2!==l?(c(d,[...n,e],o+1),s.set(e,2)):s.set(e,2)}return t}function Ve(e,n,t,o){e.push({kind:n,instanceId:t,detail:o})}function Ke(e,n){return e.find(e=>e.name===n)}function Je(e){const n=e.indexOf("::");return[e.slice(0,n),e.slice(n+2)]}function _e(e,n,t){const o=(null==e?void 0:e.onError)??"log";switch(o){case"stop":return"stop";case"log":return console.error(`[hc-canvas/wirePageBindings] binding "${t}" threw:`,n),"continue";case"continue":return"continue";default:return console.error(`[hc-canvas/wirePageBindings] binding "${t}" threw (unknown onError="${String(o)}"):`,n),"continue"}}function Xe(e,n){return e&&"passthrough"!==e.kind?"static"===e.kind?function(e){if("function"==typeof structuredClone)try{return structuredClone(e)}catch{}try{return JSON.parse(JSON.stringify(e))}catch{return[...e]}}(e.args):"pickPath"===e.kind?function(e,n){const t=[];let o;for(const i of e){const e=Ye(n,i.from);void 0===i.to?t.push(e):"number"==typeof i.to?(Ue(t,i.to+1),t[i.to]=e):(o||(t.length>0&&"object"==typeof t[0]&&null!==t[0]&&!Array.isArray(t[0])?o=t[0]:(o={},0===t.length?t.push(o):t[0]=o)),o[i.to]=e)}return t}(e.paths,n):[n]:[n]}function Ye(e,n){if(""===n)return e;const t=n.split(".");let o=e;for(const e of t){if(null==o)return;if("object"!=typeof o)return;o=o[e]}return o}function Ue(e,n){for(;e.length<n;)e.push(void 0)}function He(e,n,t,o){e.debouncePendingTimer=null;const i=e.debounceDirty,a=e.debouncePendingChainId,r=e.debouncePendingPayload;e.debouncePendingChainId=null,e.debouncePendingPayload=void 0,e.debounceDirty=!1,t&&i&&null!==a&&We(n,e).pass&&o(r,a)}function Ge(e,n,t){e.throttleTrailingTimer=null;const o=e.throttleTrailingPendingChainId,i=e.throttleTrailingPendingPayload;e.throttleTrailingPendingChainId=null,e.throttleTrailingPendingPayload=void 0,e.throttleWindowStartTs=null,null!==o&&(n.once&&e.onceConsumed||(n.once&&(e.onceConsumed=!0),e.throttleLastFireTs=en(),t(i,o)))}function We(e,n){const t=e.throttle;if(t){t.leading;const e=t.windowMs,o=en(),i=n.throttleLastFireTs;if(null!==i&&o-i<e)return{pass:!1,reason:"throttle-window"};n.throttleLastFireTs=o}if(e.once){if(n.onceConsumed)return{pass:!1,reason:"once-consumed"};n.onceConsumed=!0}return{pass:!0}}function Qe(e){return!!(e&&(e.throttle&&!1===e.throttle.leading&&!1===e.throttle.trailing||e.debounce&&!1===e.debounce.leading&&!1===e.debounce.trailing))}let Ze=()=>Date.now();function en(){return Ze()}let nn=0;function tn(e){var n,t;const o=e.canvasId,{source:i}=e,a=e.dataStore,s=new Set;let c="off",d=0,l=!1;const u="w"+ ++nn;let p=0;function f(){return`${u}-${++p}`}let h=0;function g(e){z.hasListeners("binding:trace")&&z.emit("binding:trace",{canvasId:o,ts:Date.now(),seq:++h,...e})}let v=null;a&&(v=a.attachTraceBridge(e=>{if(l)return;const n=a.getBindingsForCacheKey(e.cacheKey);for(const t of n)g({kind:e.kind,bindingId:t,cacheKey:e.cacheKey,sourceId:e.sourceId,writeSeq:e.writeSeq,reason:e.reason,payload:e.value})}));const y=new Map,m=new Map,I=new Set,w=new Set,x=new Set,b=new Set,k=new Map;let S=new Set;const M=[],T=[],z=function(){const e=new Set,n=new Set,t=new Set;return{on(o,i){if("binding:fire"===o){const n=i;return e.add(n),()=>e.delete(n)}if("binding:error"===o){const e=i;return n.add(e),()=>n.delete(e)}const a=i;return t.add(a),()=>t.delete(a)},emit(o,i){if("binding:fire"===o)for(const n of e)try{n(i)}catch(e){console.error("[hc-canvas/wirePageBindings] listener threw",e)}else if("binding:error"===o)for(const e of n)try{e(i)}catch(e){console.error("[hc-canvas/wirePageBindings] listener threw",e)}else for(const e of t)try{e(i)}catch(e){console.error("[hc-canvas/wirePageBindings] trace listener threw",e)}},hasListeners:o=>"binding:fire"===o?e.size>0:"binding:error"===o?n.size>0:t.size>0,clear(){e.clear(),n.clear(),t.clear()}}}(),B=function(e){let n=[],t=200,o=null,i=null;return{start:function(a){i&&(i(),i=null,n=[]),t=(null==a?void 0:a.capacity)??200,o=(null==a?void 0:a.filterKinds)&&a.filterKinds.length>0?new Set(a.filterKinds):null,i=e.on("binding:trace",e=>{o&&!o.has(e.kind)||(n.push(e),n.length>t&&n.shift())})},stop:function(){i&&(i(),i=null);const e=n.slice();return n=[],e},snapshot:function(){return n.slice()},get isRunning(){return null!==i}}}({on:(e,n)=>z.on(e,n)});function L(e){return void 0===e.canvasId||e.canvasId===o}function P(e){for(const n of xe(e))if(void 0!==n.canvasId&&n.canvasId!==o)return!0;return!1}function O(e){return JSON.stringify({id:e.id,type:e.type,disabled:e.disabled??!1,source:e.source,target:e.target,mapping:e.mapping??null,schedule:e.schedule??null,errorPolicy:e.errorPolicy??null})}function D(e,n){return void 0===n||O(e)!==n}function R(){var e;return(null==(e=i.getDocument())?void 0:e.bindings)??[]}function A(e){return R().find(n=>n.id===e)}function j(e){try{e()}catch(e){console.error("[hc-canvas/wirePageBindings] cleanup threw",e)}}function F(e,n){z.emit("binding:fire",e),g({kind:"fire",bindingId:e.bindingId,chainId:n,payload:e.payload,args:e.args})}function N(e,n){z.emit("binding:error",e),g({kind:(null==n?void 0:n.traceKind)??"error",bindingId:e.bindingId,chainId:null==n?void 0:n.chainId,code:e.code,message:e.message,detail:e.detail})}function q(e,n=!1){const t=y.get(e);if(t)for(const e of t)j(e);y.delete(e);const o=m.get(e);if(o){const n=function(e){const n={};return null!==e.debouncePendingTimer&&(clearTimeout(e.debouncePendingTimer),e.debouncePendingTimer=null,null!==e.debouncePendingChainId&&(n.droppedDebounce={chainId:e.debouncePendingChainId,payload:e.debouncePendingPayload})),null!==e.debouncePendingTimer||null===e.debouncePendingChainId||n.droppedDebounce||(n.droppedDebounce={chainId:e.debouncePendingChainId,payload:e.debouncePendingPayload}),e.debouncePendingChainId=null,e.debouncePendingPayload=void 0,e.debounceDirty=!1,null!==e.throttleTrailingTimer&&(clearTimeout(e.throttleTrailingTimer),e.throttleTrailingTimer=null),null!==e.throttleTrailingPendingChainId&&(n.droppedThrottleTrailing={chainId:e.throttleTrailingPendingChainId,payload:e.throttleTrailingPendingPayload}),e.throttleTrailingPendingChainId=null,e.throttleTrailingPendingPayload=void 0,e.throttleWindowStartTs=null,n}(o);n.droppedDebounce&&g({kind:"scheduled-dropped",bindingId:e,chainId:n.droppedDebounce.chainId,payload:n.droppedDebounce.payload}),n.droppedThrottleTrailing&&g({kind:"scheduled-dropped",bindingId:e,chainId:n.droppedThrottleTrailing.chainId,payload:n.droppedThrottleTrailing.payload}),m.delete(e)}w.delete(e),k.delete(e),x.delete(e),b.delete(e),s.delete(e),a&&a.removeBinding(e,{preserveCache:n})}function V(e=!1){for(const n of[...y.keys()])q(n,e)}function K(e){if(l)return;if(y.has(e.id))return;if(P(e))return void(x.has(e.id)||(N({bindingId:e.id,code:"unsupported-cross-canvas"}),x.add(e.id),g({kind:"wire-skipped",bindingId:e.id,reason:"unsupported-cross-canvas"})));const n=function(e){return e.disabled?"disabled":I.has(e.id)?"stopped":null}(e);if(n)return void g({kind:"wire-skipped",bindingId:e.id,reason:n});if("data-preview"===c&&"dataSource"!==e.source.kind)return void g({kind:"wire-skipped",bindingId:e.id,reason:"mode-matrix-data-preview"});Qe(e.schedule)&&!b.has(e.id)&&(console.warn(`[hc-canvas/wirePageBindings] schedule.{throttle|debounce}.{leading=false,trailing=false} 永远不会 fire (binding "${e.id}")`),b.add(e.id));const t=[];switch(e.source.kind){case"instanceEvent":{const n=$(e.source.instanceId,o);if(!n)return void w.add(e.id);const i=e.source.event,a=n.on(i,n=>_(e,n));t.push(a);break}case"lifecycle":case"page":break;case"dataSource":{if(!a)return void(s.has(e.id)||(N({bindingId:e.id,code:"no-data-adapter"}),g({kind:"wire-skipped",bindingId:e.id,reason:"no-data-adapter"}),s.add(e.id)));const n=e.source,t="change"===n.watch,o=n=>_(e,n),i=n=>{N({bindingId:e.id,code:"data-query-failed",message:n instanceof Error?n.message:String(n),detail:n}),"stop"===_e(e.errorPolicy,n,e.id)&&I.add(e.id)};g({kind:"data-query-started",bindingId:e.id,sourceId:n.sourceId}),t?a.subscribe({bindingId:e.id,sourceId:n.sourceId,onUpdate:o,onError:i}):a.request({bindingId:e.id,sourceId:n.sourceId,onUpdate:o,onError:i});break}default:return}y.set(e.id,t),k.set(e.id,O(e))}function J(){for(const e of R())K(e)}function _(e,n){if(l)return;if("off"===c)return;if(I.has(e.id))return void g({kind:"stopped-skipped",bindingId:e.id});if(P(e))return;if(d>=8){const n=f();return void N({bindingId:e.id,code:"cycle-detected"},{chainId:n,traceKind:"cycle-detected"})}const t=f(),o=function(e,n,t,o){return Qe(e)?{fire:!1,deferred:!1,reason:"schedule-no-fire"}:(null==e?void 0:e.debounce)?function(e,n,t,o){const i=e.debounce,a=i.leading??!1,r=i.trailing??!0,s=i.windowMs;if(null===n.debouncePendingTimer){if(a){const t=We(e,n);return t.pass?(n.debounceLeadingFireTs=en(),n.debounceDirty=!1,n.debouncePendingPayload=void 0,n.debouncePendingChainId=null,{fire:!0,deferred:!1,scheduleDeferred:t=>{n.debouncePendingTimer=setTimeout(()=>{He(n,e,r,t)},s)}}):{fire:!1,deferred:!1,reason:t.reason}}return n.debouncePendingPayload=t,n.debouncePendingChainId=o,n.debounceDirty=!0,{fire:!1,deferred:!0,scheduleDeferred:t=>{n.debouncePendingTimer=setTimeout(()=>{He(n,e,r,t)},s)}}}const c=null!==n.debouncePendingChainId?{chainId:n.debouncePendingChainId,payload:n.debouncePendingPayload}:void 0;return n.debounceDirty=!0,r&&(n.debouncePendingPayload=t,n.debouncePendingChainId=o),clearTimeout(n.debouncePendingTimer),n.debouncePendingTimer=null,r?{fire:!1,deferred:!0,droppedByReschedule:c,scheduleDeferred:t=>{n.debouncePendingTimer=setTimeout(()=>{He(n,e,r,t)},s)}}:{fire:!1,deferred:!1,reason:"debounce-window",scheduleDeferred:t=>{n.debouncePendingTimer=setTimeout(()=>{He(n,e,r,t)},s)}}}(e,n,t,o):function(e,n,t,o){const i=null==e?void 0:e.throttle;if(!i)return function(e,n){if(null==e?void 0:e.once){if(n.onceConsumed)return{fire:!1,deferred:!1,reason:"once-consumed"};n.onceConsumed=!0}return{fire:!0,deferred:!1}}(e,n);const a=i.leading??!0,r=i.trailing??!1,s=i.windowMs,c=en();if(a){const i=n.throttleLastFireTs;if(!(null!==i&&c-i<s))return(null==e?void 0:e.once)&&n.onceConsumed?{fire:!1,deferred:!1,reason:"once-consumed"}:((null==e?void 0:e.once)&&(n.onceConsumed=!0),n.throttleLastFireTs=c,{fire:!0,deferred:!1});if(!r)return{fire:!1,deferred:!1,reason:"throttle-window"};const a=null!==n.throttleTrailingPendingChainId?{chainId:n.throttleTrailingPendingChainId,payload:n.throttleTrailingPendingPayload}:void 0;if(n.throttleTrailingPendingPayload=t,n.throttleTrailingPendingChainId=o,null===n.throttleTrailingTimer){const t=s-(c-i);return{fire:!1,deferred:!0,scheduleDeferred:o=>{n.throttleTrailingTimer=setTimeout(()=>{Ge(n,e,o)},t)}}}return{fire:!1,deferred:!1,reason:"throttle-window",droppedByReschedule:a}}if(null===n.throttleWindowStartTs)return n.throttleWindowStartTs=c,n.throttleTrailingPendingPayload=t,n.throttleTrailingPendingChainId=o,{fire:!1,deferred:!0,reason:"leading-disabled",scheduleDeferred:t=>{n.throttleTrailingTimer=setTimeout(()=>{Ge(n,e,t)},s)}};const d=null!==n.throttleTrailingPendingChainId?{chainId:n.throttleTrailingPendingChainId,payload:n.throttleTrailingPendingPayload}:void 0;return n.throttleTrailingPendingPayload=t,n.throttleTrailingPendingChainId=o,{fire:!1,deferred:!1,reason:"throttle-window",droppedByReschedule:d}}(e,n,t,o)}(e.schedule,function(e){let n=m.get(e);return n||(n={onceConsumed:!1,throttleLastFireTs:null,throttleWindowStartTs:null,throttleTrailingPendingPayload:void 0,throttleTrailingPendingChainId:null,throttleTrailingTimer:null,debouncePendingTimer:null,debouncePendingPayload:void 0,debouncePendingChainId:null,debounceDirty:!1,debounceLeadingFireTs:null},m.set(e,n)),n}(e.id),n,t),i=function(e){if(e)return e.throttle?{kind:"throttle",windowMs:e.throttle.windowMs,leading:e.throttle.leading,trailing:e.throttle.trailing}:e.debounce?{kind:"debounce",windowMs:e.debounce.windowMs,leading:e.debounce.leading,trailing:e.debounce.trailing}:void 0}(e.schedule);o.droppedByReschedule&&g({kind:"scheduled-dropped",bindingId:e.id,chainId:o.droppedByReschedule.chainId,payload:o.droppedByReschedule.payload,schedule:i}),o.scheduleDeferred&&o.scheduleDeferred((n,t)=>{l||(g({kind:"scheduled-flushed",bindingId:e.id,chainId:t,payload:n,schedule:i}),X(e,n,t))}),o.reason?g({kind:"scheduled-skipped",bindingId:e.id,chainId:t,reason:o.reason,payload:n,schedule:i}):!o.deferred||o.fire?o.fire&&X(e,n,t):g({kind:"scheduled-deferred",bindingId:e.id,chainId:t,payload:n,schedule:i})}function X(e,n,t){if(l)return;const i=$(e.target.instanceId,o);if(!i)return void N({bindingId:e.id,code:"target-not-mounted"},{chainId:t});let a,r;try{a=Xe(e.mapping,n)}catch(n){return g({kind:"mapping-failed",bindingId:e.id,chainId:t,message:n instanceof Error?n.message:String(n),detail:n}),void("stop"===_e(e.errorPolicy,n,e.id)&&I.add(e.id))}if("instanceDataInput"===e.target.kind){const o=i.vm.custom,r=null==o?void 0:o[e.target.key];if(!r||"object"!=typeof r||!0!==r.dataInput)return void N({bindingId:e.id,code:"unknown-target-data-input",message:o&&e.target.key in o?`target.key "${e.target.key}" on instance "${e.target.instanceId}" is not declared with dataInput:true`:`target.key "${e.target.key}" not declared on instance "${e.target.instanceId}"`},{chainId:t});try{i.setDataInput(e.target.key,a[0])}catch(n){return"stop"===_e(e.errorPolicy,n,e.id)&&I.add(e.id),void N({bindingId:e.id,code:"invoke-failed",message:n instanceof Error?n.message:String(n),detail:n},{chainId:t})}return void F({bindingId:e.id,source:e.source,target:e.target,payload:n,args:a},t)}d++;try{r=function(e,n,t){switch(n.kind){case"instanceMethod":return e.call(n.method,...t);case"instanceEmit":return void e.emit(n.event,t[0]);default:return}}(i,e.target,a),F({bindingId:e.id,source:e.source,target:e.target,payload:n,args:a},t)}catch(n){return"stop"===_e(e.errorPolicy,n,e.id)&&I.add(e.id),void N({bindingId:e.id,code:"invoke-failed",message:n instanceof Error?n.message:String(n),detail:n},{chainId:t})}finally{d--}var s;"object"==typeof(s=r)&&null!==s&&"function"==typeof s.then&&Promise.resolve(r).catch(n=>{l||("stop"===_e(e.errorPolicy,n,e.id)&&I.add(e.id),N({bindingId:e.id,code:"invoke-failed",message:n instanceof Error?n.message:String(n),detail:n},{chainId:t}))})}const Y=null==(n=i.onAction)?void 0:n.call(i,e=>{var n,t,o,i;if(l)return;if("off"===c)return;const a=e;if(a&&"object"==typeof a)switch(a.type){case"addBinding":{const e=null==(t=null==(n=a.payload)?void 0:n.binding)?void 0:t.id;if(!e)return;const o=A(e);o&&K(o);break}case"updateBinding":{const e=null==(o=a.payload)?void 0:o.bindingId;if(!e)return;q(e);const n=A(e);n&&K(n);break}case"removeBinding":{const e=null==(i=a.payload)?void 0:i.bindingId;if(!e)return;q(e),I.delete(e);break}case"replaceDocument":V(),I.clear(),w.clear(),J();break;case"removeInstance":!function(){const e=new Set(R().map(e=>e.id));for(const n of[...y.keys()])e.has(n)||(q(n),I.delete(n));for(const e of R())K(e)}()}});Y&&M.push(Y);const U=null==(t=i.onDocumentChange)?void 0:t.call(i,()=>{if(l)return;if("off"===c)return;const e=R(),n=new Set(e.map(e=>e.id)),t=new Set(y.keys());for(const e of t)n.has(e)||q(e);for(const n of e)y.has(n.id)?D(n,k.get(n.id))&&(q(n.id),K(n)):K(n)});function H(){return new Set(E({canvasId:o}).map(e=>e.instanceId))}U&&M.push(U),S=H();const G=r(C,()=>{if(l)return;if("off"===c)return;const e=H(),n=on(e,S),t=on(S,e);S=e;for(const n of[...w]){const t=A(n);t?W(t,e)&&(w.delete(n),K(t)):w.delete(n)}if(t.size>0)for(const e of[...y.keys()]){const n=A(e);n&&(xe(n).some(e=>L(e)&&t.has(e.instanceId))&&(q(e),w.add(e)))}!function(e){if(0!==e.size)for(const n of R())"lifecycle"===n.source.kind&&"mounted"===n.source.hook&&L({canvasId:n.source.canvasId,instanceId:n.source.instanceId})&&e.has(n.source.instanceId)&&_(n,{instanceId:n.source.instanceId,hook:"mounted"})}(n),function(e){if(0!==e.size)for(const n of R())"lifecycle"===n.source.kind&&"unmounted"===n.source.hook&&L({canvasId:n.source.canvasId,instanceId:n.source.instanceId})&&e.has(n.source.instanceId)&&_(n,{instanceId:n.source.instanceId,hook:"unmounted"})}(t)},{flush:"post"});function W(e,n){for(const t of xe(e)){if(!L(t))return!1;if(!n.has(t.instanceId))return!1}return!0}return T.push(G),{setMode:function(e){l||e!==c&&(V(!0),I.clear(),w.clear(),c=e,"off"!==e&&J(),"runtime"===e&&function(){for(const e of R())"page"===e.source.kind&&"pageInit"===e.source.hook&&_(e,{hook:"pageInit"})}())},getMode:()=>c,testBinding(e,n){const t=[],i=A(e);if(!i)return t.push({bindingId:e,phase:"skipped",details:{reason:"binding-not-found"}}),t;if(i.disabled)return t.push({bindingId:e,phase:"skipped",details:{reason:"disabled"}}),t;if(P(i))return t.push({bindingId:e,phase:"skipped",details:{reason:"unsupported-cross-canvas"}}),t;let a;try{a=Xe(i.mapping,n),t.push({bindingId:e,phase:"mapping",details:{payload:n,args:a}})}catch(n){return t.push({bindingId:e,phase:"error",details:{stage:"mapping",message:n instanceof Error?n.message:String(n)}}),t}const r=$(i.target.instanceId,o);if(!r)return t.push({bindingId:e,phase:"skipped",details:{reason:"target-not-mounted"}}),t;if("instanceDataInput"===i.target.kind){const n=r.vm.custom,o=null==n?void 0:n[i.target.key];if(!o||"object"!=typeof o||!0!==o.dataInput)return t.push({bindingId:e,phase:"skipped",details:{reason:"unknown-target-data-input",key:i.target.key}}),t}return t.push({bindingId:e,phase:"calling-target",details:{target:i.target,dryRun:!0}}),t.push({bindingId:e,phase:"done",details:{args:a}}),t},on:(e,n)=>z.on(e,n),startTracing(e){B.start(e)},stopTracing:()=>B.stop(),getTraceBuffer:()=>B.snapshot(),dispose:function(){if(!l){"runtime"===c&&function(){for(const e of R())"page"===e.source.kind&&"pageBeforeUnmount"===e.source.hook&&_(e,{hook:"pageBeforeUnmount"})}(),l=!0,V();for(const e of M)j(e);for(const e of T)j(e);M.length=0,T.length=0,I.clear(),w.clear(),x.clear(),b.clear(),k.clear(),S.clear(),m.clear(),B.stop(),z.clear(),v&&(v(),v=null),c="off"}}}}function on(e,n){const t=new Set;for(const o of e)n.has(o)||t.add(o);return t}const an=["data-hc-canvas-id"],rn=["data-instance-id","data-hc-hidden"],sn={key:0,class:"hc-page-instance-fallback",style:{width:"100%",height:"100%",border:"2px dashed #f59e0b",background:"#fef3c7",color:"#92400e",padding:"8px",fontSize:"11px",fontFamily:"monospace",overflow:"hidden",borderRadius:"4px",boxSizing:"border-box"}},cn={style:{opacity:"0.8"}},dn={style:{opacity:"0.6","margin-top":"4px","word-break":"break-all"}},ln={key:2,class:"hc-page-instance-skeleton",style:{width:"100%",height:"100%",background:"linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%)",backgroundSize:"200% 100%",animation:"hc-skeleton-shimmer 1.5s infinite ease-in-out",borderRadius:"4px",boxSizing:"border-box"}},un=["data-instance-id","data-hc-placement","data-hc-hidden"],pn={key:0,class:"hc-page-instance-fallback",style:{width:"100%",height:"100%",border:"2px dashed #f59e0b",background:"#fef3c7",color:"#92400e",padding:"8px","font-size":"11px","font-family":"monospace",overflow:"hidden","border-radius":"4px","box-sizing":"border-box"}},fn={style:{opacity:"0.6"}},hn=["title"],gn={key:1,class:"hc-page-renderer-empty",style:{padding:"24px",color:"#64748b","font-size":"13px"}},vn=s({__name:"HyperCardPageRenderer",props:{payload:{},document:{},componentSourceMap:{},schedulerOptions:{},canvasId:{},adapters:{}},setup(e,{expose:i}){var s,M;const T=e,z=T.canvasId??function(){var e;const n="undefined"!=typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;return`auto-${(null==(e=null==n?void 0:n.randomUUID)?void 0:e.call(n).replace(/-/g,"").slice(0,8))??Math.random().toString(36).slice(2,10)}`}();a(O,z);const B=we(T.schedulerOptions),L=o(null);let P=!1;c(()=>{ce||d(()=>{var e;if(P)return;if(!L.value)return;if("fill"!==(null==(e=te.value)?void 0:e.canvas.height.mode))return;const n=L.value.parentElement;n&&(n.getBoundingClientRect().height>0||(P=!0,console.warn("[hypercard] HyperCardPageRenderer 父容器高度为 0,fill 模式画布不可见。请给父容器设置明确 height 或改用 px 模式。")))})}),l(()=>{le.value&&(le.value.dispose(),le.value=null),B.dispose(),ue&&ue.disposeAll(),z!==D&&R(z)});const C=o(new Map),$=o(new Map),E=new Map;function j(e,n){const t=new Map;n.querySelectorAll("[data-hc-slot]").forEach(e=>{if(e.closest("[data-instance-id]")!==n)return;const o=e.getAttribute("data-hc-slot")||je;t.has(o)||t.set(o,e)});const o=new Map($.value);o.set(e,t),$.value=o}function F(e,n){const t=C.value.get(e);n&&n!==t?(C.value.set(e,n),B.register(e,n),function(e,n){const t=E.get(e);t&&t.disconnect(),j(e,n);const o=new MutationObserver(()=>j(e,n));o.observe(n,{childList:!0,subtree:!0}),E.set(e,o)}(e,n)):!n&&t&&(B.unregister(e),C.value.delete(e),function(e){const n=E.get(e);if(n&&(n.disconnect(),E.delete(e)),$.value.has(e)){const n=new Map($.value);n.delete(e),$.value=n}}(e))}l(()=>{for(const e of E.values())e.disconnect();E.clear(),$.value=new Map});const N=n(()=>{var e;const n=(null==(e=T.payload)?void 0:e.document)??T.document??null;return n?J(K(n)):null}),q=n(()=>T.payload?T.payload.componentVersions:T.componentSourceMap??{}),V=n(()=>{const e=N.value,n=q.value;return e?e.instances.map(t=>{var o;const i=n[t.componentVersionKey]??null,a=(null==(o=e.componentOverrides)?void 0:o[t.instanceId])??null,r=a&&a.baseVersionKey===t.componentVersionKey?a:null,s=r?`${r.baseVersionKey}#override:${t.instanceId}`:t.componentVersionKey;if(r)return{instance:t,asset:i,override:r,renderSource:r.source,scopeId:s,status:"ok"};if(!i)return{instance:t,asset:null,override:null,renderSource:null,scopeId:s,status:"missing-source",invalidReason:`componentVersionKey "${t.componentVersionKey}" not in sourceMap`};if("ok"!==i.status)return{instance:t,asset:i,override:null,renderSource:null,scopeId:s,status:"unavailable",invalidReason:i.invalidReason??`component version unavailable (${i.status})`};let c=null;return c=function(e){return!!e&&!0===e.isDraft}(i)?i.lastGoodSource:i.source??null,c?{instance:t,asset:i,override:null,renderSource:c,scopeId:s,status:"ok"}:{instance:t,asset:i,override:null,renderSource:null,scopeId:s,status:"missing-source",invalidReason:"asset.status=ok but source missing"}}):[]});function _(e){const n=q.value[e];return null==n?void 0:n.contract}const X=n(()=>{const e=N.value;return e?qe(e,{resolveContract:_}):[]}),Y=t(Oe,null);r(X,e=>{Y&&"function"==typeof Y.setLayoutIssues&&Y.setLayoutIssues(e)},{immediate:!0});const U=n(()=>{const e=new Set;for(const n of X.value)"missing-parent"!==n.kind&&"invalid-slot"!==n.kind&&"parent-not-layout"!==n.kind&&"orphan-slot"!==n.kind&&"cycle"!==n.kind&&"absolute-child-rejected"!==n.kind||e.add(n.instanceId);return e}),H=n(()=>V.value.filter(e=>void 0===e.instance.parentId)),G=n(()=>V.value.filter(e=>void 0!==e.instance.parentId&&ve(e.instance.placement)));function W(e){const n=e.layoutBox??{x:e.rect.x,y:e.rect.y,width:e.rect.w,height:e.rect.h,widthMode:"px",heightMode:"px",overflow:"hidden"},t=function(e){const n=N.value;if(n)return ye(te.value??void 0,n.instances,e.instanceId)}(e),o=oe(n,e.zIndex,e.rotation,t),i=re(e.layoutItem,t);return i&&Object.assign(o,i),o}const Q=n(()=>{var e;return ae(null==(e=te.value)?void 0:e.rootLayout)});function Z(e){if(!e.parentId)return null;const n=$.value.get(e.parentId);return n?n.get(Ne(e))??null:null}function ee(e){return{position:"absolute",left:"8px",top:8+28*G.value.indexOf(e)+"px",padding:"4px 8px",background:"hsla(40, 90%, 50%, 0.95)",color:"#5b3a00",fontSize:"11px",fontFamily:"ui-monospace, monospace",borderRadius:"4px",zIndex:9999,maxWidth:"60%",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"}}function ne(e){return"实例 "+e.instance.instanceId+':slot "'+Ne(e.instance)+'" 不可用'}const te=n(()=>{var e;return(null==(e=N.value)?void 0:e.layout)??null}),ie=n(()=>{if(!te.value)return null;if(ce){const e=ce.measuredCanvasSize.value;return{width:`${e.w}px`,height:`${e.h}px`,overflow:te.value.canvas.overflow??"hidden"}}return{width:se(te.value.canvas.width),height:se(te.value.canvas.height),overflow:te.value.canvas.overflow??"hidden"}}),ce=t(Oe,void 0),de=ce?null:Ce(null==(s=T.adapters)?void 0:s.assets),le=u(null),ue=ce||!(null==(M=T.adapters)?void 0:M.data)?null:$e(T.adapters.data);if(!ce){const e=tn({canvasId:z,source:{getDocument:()=>N.value,onDocumentChange:e=>r(N,e,{flush:"post"})},dataStore:ue??void 0});le.value=e,d(()=>{e.setMode("runtime")})}i({binding:le,data:ce?{invalidateDataSource(e){ce.dataStore.invalidate(e)},getDataSourceSnapshot:()=>ce.dataStore.getSnapshot()}:ue?{invalidateDataSource(e){ue.invalidate(e)},getDataSourceSnapshot:()=>ue.getSnapshot()}:null});const pe=o(null);let fe=0;r(()=>{var e,n;return null==(n=null==(e=te.value)?void 0:e.background)?void 0:n.image},e=>{fe++;const n=fe;if(!e)return void(pe.value=null);const t=(o=e,ce?ce.resolveAsset(o):de.resolve(o));var o;"string"!=typeof t?(pe.value=null,t.then(t=>{var o,i;n===fe&&(null==(i=null==(o=te.value)?void 0:o.background)?void 0:i.image)===e&&(pe.value=t||null)},()=>{n===fe&&(pe.value=null)})):pe.value=t||null},{immediate:!0,deep:!0});const he=n(()=>{var e;const n=null==(e=te.value)?void 0:e.background;if(!n)return null;const t={position:"absolute",inset:"0",pointerEvents:"none",zIndex:-1};return n.color&&(t.background=n.color),n.image&&pe.value&&(t.backgroundImage=`url("${pe.value}")`,t.backgroundRepeat="repeat"===n.imageFit?"repeat":"no-repeat",t.backgroundPosition=n.imagePosition??"center","stretch"===n.imageFit?t.backgroundSize="100% 100%":n.imageFit&&"repeat"!==n.imageFit&&"center"!==n.imageFit&&(t.backgroundSize=n.imageFit)),void 0!==n.opacity&&(t.opacity=n.opacity),t});return(e,n)=>te.value&&ie.value?(p(),f("div",{key:0,ref_key:"rootEl",ref:L,class:"hc-page-renderer","data-hc-canvas-id":g(z),style:h({position:"relative",...ie.value,...Q.value??{}})},[he.value?(p(),f("div",{key:0,class:"hc-canvas-bg","data-hc-canvas-bg":"",style:h(he.value)},null,4)):v("",!0),(p(!0),f(y,null,m(H.value,e=>I((p(),f("div",{key:e.instance.instanceId,ref_for:!0,ref:n=>F(e.instance.instanceId,n),"data-instance-id":e.instance.instanceId,"data-hc-hidden":e.instance.hidden?"true":void 0,style:h(W(e.instance))},["ok"===e.status&&e.renderSource?g(B).isMounted(e.instance.instanceId)?(p(),b(g(A),{key:1,"canvas-id":g(z),"instance-id":e.instance.instanceId,"component-id":e.instance.componentId,"scope-id":e.scopeId,"html-source":e.renderSource.html,"js-source":e.renderSource.js,"css-source":e.renderSource.css,"custom-values":{...e.instance.props,__containerLayout:e.instance.containerLayout}},null,8,["canvas-id","instance-id","component-id","scope-id","html-source","js-source","css-source","custom-values"])):(p(),f("div",ln)):(p(),f("div",sn,[n[0]||(n[0]=w("div",{style:{"font-weight":"600","margin-bottom":"4px"}}," ⚠️ 组件不可渲染 ",-1)),w("div",cn,x(e.instance.alias??e.instance.instanceId),1),w("div",dn,x(e.invalidReason),1)]))],12,rn)),[[k,!e.instance.hidden]])),128)),(p(!0),f(y,null,m(G.value,e=>(p(),f(y,{key:`child-${e.instance.instanceId}`},[Z(e.instance)&&!U.value.has(e.instance.instanceId)?(p(),b(S,{key:0,to:Z(e.instance)},[I(w("div",{ref_for:!0,ref:n=>F(e.instance.instanceId,n),"data-instance-id":e.instance.instanceId,"data-hc-placement":e.instance.placement,"data-hc-hidden":e.instance.hidden?"true":void 0,style:h(W(e.instance))},["ok"===e.status&&e.renderSource?(p(),b(g(A),{key:1,"canvas-id":g(z),"instance-id":e.instance.instanceId,"component-id":e.instance.componentId,"scope-id":e.scopeId,"html-source":e.renderSource.html,"js-source":e.renderSource.js,"css-source":e.renderSource.css,"custom-values":{...e.instance.props,__containerLayout:e.instance.containerLayout}},null,8,["canvas-id","instance-id","component-id","scope-id","html-source","js-source","css-source","custom-values"])):(p(),f("div",pn,[n[1]||(n[1]=w("div",{style:{"font-weight":"600"}},"⚠️ 组件不可渲染",-1)),w("div",fn,x(e.invalidReason),1)]))],12,un),[[k,!e.instance.hidden]])],8,["to"])):(p(),f("div",{key:1,class:"hc-layout-issue-warning",title:ne(e),style:h(ee(e))}," ⚠ 布局问题:"+x(e.instance.instanceId)+'(slot "'+x(g(Ne)(e.instance))+'") ',13,hn))],64))),128))],12,an)):(p(),f("div",gn," No page to render(payload / document 都未提供) "))}}),yn=new Map,mn=new Set;function In(){const e=Object.freeze(Array.from(yn.keys()));for(const n of mn)try{n(e)}catch{}}function wn(e,n){yn.set(e,n),In()}function xn(e){yn.delete(e)&&In()}function bn(e){return yn.get(e)??null}function kn(){return Object.freeze(Array.from(yn.keys()))}function Sn(e){return mn.add(e),()=>{mn.delete(e)}}function Mn(e,n){var t;const o=n.document;switch(e.type){case"addInstance":{const{instance:n}=e.payload;return o.getInstance(n.instanceId)?null:[{type:"removeInstance",payload:{instanceId:n.instanceId}}]}case"removeInstance":{const{instanceId:n}=e.payload,t=o.getInstance(n);if(!t)return null;const i=o.document.bindings.filter(e=>be(e,n)),a=[{type:"addInstance",payload:{instance:zn(t)}}];for(const e of i)a.push({type:"addBinding",payload:{binding:j(e)}});return a}case"updateInstance":{const{instanceId:n,patch:t}=e.payload,i=o.getInstance(n);if(!i)return null;const a={};for(const e of Object.keys(t)){const n=i[e];a[e]=Tn(n)?j(n):n}return[{type:"updateInstance",payload:{instanceId:n,patch:a}}]}case"moveInstance":{const{instanceId:n,x:t,y:i}=e.payload,a=o.getInstance(n);return a?a.rect.x===t&&a.rect.y===i?null:a.layoutBox?[{type:"updateLayoutBox",payload:{instanceId:n,patch:{...a.layoutBox}}}]:[{type:"moveInstance",payload:{instanceId:n,x:a.rect.x,y:a.rect.y}}]:null}case"resizeInstance":{const{instanceId:n,w:t,h:i}=e.payload,a=o.getInstance(n);return a?a.rect.w===t&&a.rect.h===i?null:a.layoutBox?[{type:"updateLayoutBox",payload:{instanceId:n,patch:{...a.layoutBox}}}]:[{type:"resizeInstance",payload:{instanceId:n,w:a.rect.w,h:a.rect.h}}]:null}case"setInstanceProp":{const{instanceId:n,key:t,value:i}=e.payload,a=o.getInstance(n);return a?a.props[t]===i?null:[{type:"updateInstance",payload:{instanceId:n,patch:{props:{...a.props}}}}]:null}case"addBinding":{const{binding:n}=e.payload;return o.document.bindings.some(e=>e.id===n.id)?null:[{type:"removeBinding",payload:{bindingId:n.id}}]}case"removeBinding":{const{bindingId:n}=e.payload,t=o.document.bindings.find(e=>e.id===n);return t?[{type:"addBinding",payload:{binding:j(t)}}]:null}case"updateBinding":{const{bindingId:n,patch:t}=e.payload,i=o.document.bindings.find(e=>e.id===n);if(!i)return null;const a={};for(const e of Object.keys(t)){const n=i[e];a[e]=Tn(n)?j(n):n}return[{type:"updateBinding",payload:{bindingId:n,patch:a}}]}case"updateLayout":{const{patch:n}=e.payload,t={};for(const e of Object.keys(n)){const n=o.document.layout[e];t[e]=Tn(n)?j(n):n}return[{type:"updateLayout",payload:{patch:t}}]}case"setRootLayout":{const{rootLayout:n}=e.payload,t=o.document.layout.rootLayout,i=void 0!==t;return i||null!==n?[{type:"setRootLayout",payload:{rootLayout:i?j(t):null}}]:null}case"setComponentOverride":{const{instanceId:n,override:i}=e.payload;if(void 0===o.getInstance(n))return null;const a=null==(t=o.document.componentOverrides)?void 0:t[n],r=void 0!==a;return r||null!==i?[{type:"setComponentOverride",payload:{instanceId:n,override:r?j(a):null}}]:null}case"replaceDocument":return[{type:"replaceDocument",payload:{document:j(o.document)}}];case"setInstanceLocked":{const{instanceId:n,locked:t}=e.payload,i=o.getInstance(n);if(!i)return null;const a=i.locked??!1,r=i.lockPosition,s=i.lockSize;return a===t&&r===(!!t||void 0)&&s===(!!t||void 0)?null:[{type:"updateInstance",payload:{instanceId:n,patch:{locked:a,lockPosition:r,lockSize:s}}}]}case"duplicateInstance":{const{instanceId:n,newInstanceId:t}=e.payload;return o.getInstance(n)?o.getInstance(t)?null:[{type:"removeInstance",payload:{instanceId:t}}]:null}case"setInstanceSize":{const{instanceId:n,size:t}=e.payload,i=o.getInstance(n);if(!i)return null;const a=i.size,r="size"in i&&void 0!==a;return r||null!==t?[{type:"setInstanceSize",payload:{instanceId:n,size:(r?j(a):null)??null}}]:null}case"setContainerLayout":{const{instanceId:n,containerLayout:t}=e.payload,i=o.getInstance(n);if(!i)return null;const a=i.containerLayout,r="containerLayout"in i&&void 0!==a;return r||null!==t?[{type:"setContainerLayout",payload:{instanceId:n,containerLayout:(r?j(a):null)??null}}]:null}case"updateLayoutBox":{const{instanceId:n,patch:t}=e.payload,i=o.getInstance(n);if(!i)return null;const a=i.layoutBox??{x:i.rect.x,y:i.rect.y,width:i.rect.w,height:i.rect.h,widthMode:"px",heightMode:"px",overflow:"hidden"},r={};let s=!1;const c=["x","y","width","height"];for(const e of c){const n=t[e];"number"==typeof n&&Number.isFinite(n)&&(r[e]=a[e],s=!0)}return"px"!==t.widthMode&&"percent"!==t.widthMode&&"fill"!==t.widthMode&&"auto"!==t.widthMode||(r.widthMode=a.widthMode,s=!0),"px"!==t.heightMode&&"percent"!==t.heightMode&&"fill"!==t.heightMode&&"auto"!==t.heightMode||(r.heightMode=a.heightMode,s=!0),"hidden"!==t.overflow&&"visible"!==t.overflow&&"auto"!==t.overflow||(r.overflow=a.overflow,s=!0),s?[{type:"updateLayoutBox",payload:{instanceId:n,patch:r}}]:null}case"updateLayoutItem":{const{instanceId:n,patch:t}=e.payload,i=o.getInstance(n);if(!i)return null;const a=i.layoutItem,r="layoutItem"in i&&void 0!==a,s=null===t;if(!r&&s)return null;if(!s){const e=["order","grow","shrink","row","column","rowSpan","columnSpan","ratio"];let n=!1;for(const o of e){const e=t[o];if("number"==typeof e&&Number.isFinite(e)){n=!0;break}}if(!n)return null}return[{type:"updateLayoutItem",payload:{instanceId:n,patch:(r?j(a):null)??null}}]}case"updateRotation":{const{instanceId:n,value:t}=e.payload,i=o.getInstance(n);if(!i)return null;if(!Number.isFinite(t))return null;const a=i.rotation,r="number"==typeof a&&Number.isFinite(a)?a:0;return r===t?null:[{type:"updateRotation",payload:{instanceId:n,value:r}}]}case"select":case"toggleSelect":case"addToSelection":case"removeFromSelection":case"clearSelection":case"selectAll":return null;default:{const n=e;return console.warn("[hc-canvas/computeInverse] unknown action",n),null}}}function Tn(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function zn(e){return j(e)}function Bn(e,t={}){const i=t.maxSize??100,a=o([]),r=o([]);let s={redo:[],undo:[]},c=null;function d(e){var n;0===s.redo.length&&0===s.undo.length||(n={type:e,redo:s.redo,undo:s.undo,timestamp:Date.now()},a.value.push(n),a.value.length>i&&a.value.shift(),r.value.length>0&&(r.value=[]),s={redo:[],undo:[]},c=null)}const l={onBeforeAction(n){if(e.isRecordingSuppressed.value)return;const t=Mn(n,e);if(null!==t){s.redo.push(n);for(let e=t.length-1;e>=0;e--)s.undo.unshift(t[e]);c=n.type}},onAfterAction(n){e.isRecordingSuppressed.value||e.isBatching.value||d(c??"action")},onAfterBatch(n){e.isRecordingSuppressed.value||d(n??"batch")}},u=e.registerHooks(l);function p(){a.value=[],r.value=[],s={redo:[],undo:[]},c=null}return{undo:function(){if(0===a.value.length)return;const n=a.value.pop();e.suppressRecording(()=>{e.beginBatch();for(const t of n.undo)e.dispatch(t);e.endBatch("undo")}),r.value.push(n)},redo:function(){if(0===r.value.length)return;const n=r.value.pop();e.suppressRecording(()=>{e.beginBatch();for(const t of n.redo)e.dispatch(t);e.endBatch("redo")}),a.value.push(n)},clear:p,canUndo:n(()=>a.value.length>0),canRedo:n(()=>r.value.length>0),undoStackSize:n(()=>a.value.length),redoStackSize:n(()=>r.value.length),dispose:function(){u(),p()}}}function Ln(e,n,t){let o=null;for(const i of e)for(const e of n){const n=e.pos-i,a=Math.abs(n);a<=t&&(!o||a<Math.abs(o.delta))&&(o={delta:n,candidate:e,targetPos:i})}return o}function Pn(e){var n,t,o,i;const a=e.threshold??5,r=function(e){if(0===e.length)return null;let n=1/0,t=-1/0,o=1/0,i=-1/0;for(const a of e)a.x<n&&(n=a.x),a.x+a.w>t&&(t=a.x+a.w),a.y<o&&(o=a.y),a.y+a.h>i&&(i=a.y+a.h);return{left:n,right:t,top:o,bottom:i,centerX:(n+t)/2,centerY:(o+i)/2,width:t-n,height:i-o}}(e.draggedRects);if(!r)return{dx:0,dy:0,lines:[]};const s=function(e,n,t){const o=[];for(const n of e)o.push({pos:n.x,kind:"edge-left",source:n}),o.push({pos:n.x+n.w,kind:"edge-right",source:n}),o.push({pos:n.x+n.w/2,kind:"center-x",source:n});if(o.push({pos:0,kind:"canvas-edge"}),o.push({pos:n.w,kind:"canvas-edge"}),o.push({pos:n.w/2,kind:"canvas-edge"}),t)for(const e of t)o.push({pos:e,kind:"guide"});return o}(e.otherRects,e.canvasSize,null==(n=e.manualGuides)?void 0:n.x),c=function(e,n,t){const o=[];for(const n of e)o.push({pos:n.y,kind:"edge-top",source:n}),o.push({pos:n.y+n.h,kind:"edge-bottom",source:n}),o.push({pos:n.y+n.h/2,kind:"center-y",source:n});if(o.push({pos:0,kind:"canvas-edge"}),o.push({pos:n.h,kind:"canvas-edge"}),o.push({pos:n.h/2,kind:"canvas-edge"}),t)for(const e of t)o.push({pos:e,kind:"guide"});return o}(e.otherRects,e.canvasSize,null==(t=e.manualGuides)?void 0:t.y),d=[r.left,r.right,r.centerX],l=[r.top,r.bottom,r.centerY],u=Ln(d,s,a),p=Ln(l,c,a),f=(null==u?void 0:u.delta)??0,h=(null==p?void 0:p.delta)??0,g=[];if(u){const n=(null==(o=u.candidate.source)?void 0:o.y)??0,t=u.candidate.source?u.candidate.source.y+u.candidate.source.h:e.canvasSize.h,i=Math.min(r.top+h,n),a=Math.max(r.bottom+h,t);g.push({axis:"x",pos:u.candidate.pos,from:i,to:a,kind:u.candidate.kind})}if(p){const n=(null==(i=p.candidate.source)?void 0:i.x)??0,t=p.candidate.source?p.candidate.source.x+p.candidate.source.w:e.canvasSize.w,o=Math.min(r.left+f,n),a=Math.max(r.right+f,t);g.push({axis:"y",pos:p.candidate.pos,from:o,to:a,kind:p.candidate.kind})}return{dx:f,dy:h,lines:g}}const Cn=3,$n=8;function En(e){return e.shift||e.ctrl||e.meta}function On(e,n,t){const o=n.getBoundingClientRect(),i={x:e.x-o.left,y:e.y-o.top};return t.toCanvasPoint(i)}function Dn(e,n,t){const o=new Map;for(let e=0;e<n.length;e++)o.set(n[e].instanceId,e);const i=new Map;function a(e){const t=i.get(e);if(t)return t;const o=[];let a=e;const r=new Set;for(;a&&!r.has(a);){r.add(a),o.push(a);const e=n.find(e=>e.instanceId===a);if(!(null==e?void 0:e.parentId))break;a=e.parentId}const s=o.reverse();return i.set(e,s),s}function r(e,t){const i=a(e),r=a(t);let s=0;for(;s<i.length&&s<r.length&&i[s]===r[s];)s++;if(s===i.length&&s===r.length)return 0;if(s===i.length)return-1;if(s===r.length)return 1;const c=i[s],d=r[s],l=n.find(e=>e.instanceId===c),u=n.find(e=>e.instanceId===d),p=(null==l?void 0:l.zIndex)??0,f=(null==u?void 0:u.zIndex)??0;return p!==f?p-f:(o.get(c)??-1)-(o.get(d)??-1)}let s=null,c=-1;for(let o=0;o<n.length;o++){const i=n[o];if(i.hidden)continue;const a=(null==t?void 0:t(i.instanceId))??i.rect;if(!(e.x>=a.x&&e.x<=a.x+a.w&&e.y>=a.y&&e.y<=a.y+a.h))continue;if(null===s){s=i.instanceId,c=o;continue}const d=r(i.instanceId,s);let l;l=d>0||!(d<0)&&o>c,l&&(s=i.instanceId,c=o)}return s}function Rn(e,n){return{x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),w:Math.abs(e.x-n.x),h:Math.abs(e.y-n.y)}}function An(e,n,t){const o=[];for(const i of n){if(i.hidden)continue;const n=(null==t?void 0:t(i.instanceId))??i.rect;n.x>=e.x&&n.y>=e.y&&n.x+n.w<=e.x+e.w&&n.y+n.h<=e.y+e.h&&o.push(i.instanceId)}return o}const jn=["e","s","se"];function Fn(e,n){if(!e||"function"!=typeof e.querySelector)return null;const t=e.querySelector(n);if(t)return t;if(e instanceof Element&&"function"==typeof e.closest){const t=e.closest("[data-hc-canvas-designer]");if(t&&t!==e){const e=t.querySelector(n);if(e)return e}}return null}function Nn(e,n,t){var o;const i=t??("undefined"!=typeof document&&"function"==typeof document.querySelector?document:null);if(!i)return null;const a=n??"default",r=""===a?"default":a,s="undefined"!=typeof globalThis&&(null==(o=globalThis.CSS)?void 0:o.escape)?globalThis.CSS.escape:e=>e.replace(/["\\]/g,e=>`\\${e}`),c=Fn(i,`[data-instance-id="${s(e)}"] [data-hc-slot="${s(r)}"]`);return c&&c instanceof HTMLElement?c.getBoundingClientRect():null}function qn(e,n){var t;const o=n??("undefined"!=typeof document&&"function"==typeof document.querySelector?document:null);if(!o)return null;const i="undefined"!=typeof globalThis&&(null==(t=globalThis.CSS)?void 0:t.escape)?globalThis.CSS.escape:e=>e.replace(/["\\]/g,e=>`\\${e}`),a=o.querySelector(`[data-instance-id="${i(e)}"][data-hc-placement="slot"]`);return a&&a instanceof HTMLElement?a.getBoundingClientRect():null}function Vn(e,n,t){var o;const i=n??("undefined"!=typeof document&&"function"==typeof document.querySelector?document:null);if(!i)return null;if("function"!=typeof i.querySelector)return null;const a=`[data-instance-id="${("undefined"!=typeof globalThis&&(null==(o=globalThis.CSS)?void 0:o.escape)?globalThis.CSS.escape:e=>e.replace(/["\\]/g,e=>`\\${e}`))(e)}"]`,r=t?Fn(i,a):i.querySelector(a);return r&&r instanceof HTMLElement?r.getBoundingClientRect():null}function Kn(e,n){return ye(e.document.document.layout,e.document.document.instances,n)}function Jn(e){return"free"===e||"none"===e||void 0===e}function _n(e,n,t){if(!n)return null;const o=Vn(e,n,!0);if(!o)return null;const i=n.getBoundingClientRect(),a=t.toCanvasPoint({x:o.left-i.left,y:o.top-i.top}),r=t.toCanvasPoint({x:o.right-i.left,y:o.bottom-i.top});return{x:a.x,y:a.y,w:Math.max(0,r.x-a.x),h:Math.max(0,r.y-a.y)}}function Xn(e,n,t){const o=Math.max(8,n);if(!e)return{mode:"px",value:o};switch(e.mode){case"px":return{...e,mode:"px",value:o};case"percent":{if(!t||t<=0)return{...e,mode:"px",value:o};const n=o/t*100,i=Math.max(0,Math.min(1e3,n));return{...e,mode:"percent",value:i}}case"fill":case"hug":case"auto":return{mode:"px",value:o,min:e.min,max:e.max}}}function Yn(e,n,t){const o=Math.max(8,n);switch(e){case"px":case"fill":case"auto":default:return{mode:"px",value:o};case"percent":{if(!t||t<=0)return{mode:"px",value:o};const e=o/t*100;return{mode:"percent",value:Math.max(0,Math.min(1e3,e))}}}}function Un(e,n){const t=new Set(n.map(e=>e.instanceId));return e.filter(e=>t.has(e))}function Hn(t,i={}){const a=e({active:!1,start:null,end:null,additive:!1,priorSelection:[]}),r=e({status:"idle",startPt:null,startRects:new Map,deferredClickSelect:null}),s=e({status:"idle",handle:null,startPt:null,startRect:null,instanceId:null,placement:null,parentLayoutMode:void 0,startSize:null,startLayoutBox:null,startOutletCanvasSize:null}),c=o([]),d=o(null);let l=0;const u=o(null);let p=0;const f=n(()=>a.active&&a.start&&a.end?Rn(a.start,a.end):null),h=n(()=>"active"===r.status),g=n(()=>"active"===s.status);function v(){a.active=!1,a.start=null,a.end=null,a.additive=!1,a.priorSelection=[]}function y(){r.status="idle",r.startPt=null,r.startRects=new Map,r.deferredClickSelect=null,c.value=[]}function m(){s.status="idle",s.handle=null,s.startPt=null,s.startRect=null,s.instanceId=null,s.placement=null,s.startSize=null,s.startOutletCanvasSize=null,s.parentLayoutMode=void 0,s.startLayoutBox=null}return{marquee:a,marqueeRect:f,drag:r,isDragging:h,resize:s,isResizing:g,snapLines:c,cannotDragSlotChildEvent:d,cannotDragLayoutManagedChildEvent:u,handlePointerDown(e,n){var o;const s=t.effectiveBehavior.value;if(!s.selectable)return{startTracking:!1};const c=t.toolMode.value;if("hand"===c)return{startTracking:!1};const f=En(n),h="marquee"===c?null:Dn(e,t.document.document.instances,i.getDomBox);if(h){const n=t.document.getInstance(h),i=!0===((null==n?void 0:n.lockPosition)??(null==n?void 0:n.locked)),a=t.selection.selectedIds.value.includes(h),g=t.selection.size.value>1;f?t.dispatch({type:"toggleSelect",payload:{instanceId:h}}):i?t.dispatch({type:"select",payload:{instanceId:h}}):a&&g&&s.draggable&&"inspect"!==c?r.deferredClickSelect=h:t.dispatch({type:"select",payload:{instanceId:h}});const v="slot"===(null==n?void 0:n.placement)||"container"===(null==n?void 0:n.placement),y=Kn(t,h),m="inspect"===c;if(i||!s.draggable||m||(null==n?void 0:n.hidden))return{startTracking:!1};if(!Jn(y)){if(!f){p++;const e={instanceId:h,parentId:null==n?void 0:n.parentId,parentLayoutMode:y,token:p};u.value=e,null==(o=t.setCannotDragLayoutManagedChildEvent)||o.call(t,e),v&&(l++,d.value={instanceId:h,parentId:null==n?void 0:n.parentId,token:l})}return{startTracking:!1}}return r.status="pending",r.startPt={...e},r.startRects=function(){const e=t.selection.selectedIds.value,n=new Map;for(const o of e){const e=t.document.getInstance(o);e&&!0!==(e.lockPosition??e.locked)&&n.set(o,{x:e.rect.x,y:e.rect.y})}return n}(),{startTracking:!0}}return f||t.dispatch({type:"clearSelection"}),a.active=!0,a.start={...e},a.end={...e},a.additive=f,a.priorSelection=f?[...t.selection.selectedIds.value]:[],{startTracking:!0}},handlePointerMove(e){var n,o;if("active"===s.status&&s.startPt&&s.startRect&&s.instanceId){const n=e.x-s.startPt.x,o=e.y-s.startPt.y,i=s.startRect,a=s.handle,r=t.document.getInstance(s.instanceId);if(!r)return;const c=s.parentLayoutMode,d="flex"===c||"grid"===c;let l=i.x,u=i.y,p=i.w,f=i.h;"e"===a||"ne"===a||"se"===a?p=i.w+n:d||"w"!==a&&"nw"!==a&&"sw"!==a||(p=i.w-n,l=i.x+n),"s"===a||"se"===a||"sw"===a?f=i.h+o:d||"n"!==a&&"ne"!==a&&"nw"!==a||(f=i.h-o,u=i.y+o),p<8&&(d||"w"!==a&&"nw"!==a&&"sw"!==a||(l=i.x+i.w-8),p=8),f<8&&(d||"n"!==a&&"nw"!==a&&"ne"!==a||(u=i.y+i.h-8),f=8);const h=s.startLayoutBox,g=s.startOutletCanvasSize,v="e"===a||"ne"===a||"se"===a||!d&&("w"===a||"nw"===a||"sw"===a),y="s"===a||"se"===a||"sw"===a||!d&&("n"===a||"ne"===a||"nw"===a),m=!d&&("w"===a||"nw"===a||"sw"===a),I=!d&&("n"===a||"ne"===a||"nw"===a),w=v?Yn(h.widthMode,p,g?g.w:null):null,x=y?Yn(h.heightMode,f,g?g.h:null):null,b="canvas"===s.placement||"absolute"===s.placement,k=!(w&&"px"!==w.mode||x&&"px"!==x.mode||v&&"px"!==h.widthMode||y&&"px"!==h.heightMode);if(b&&k)(v&&r.rect.w!==p||y&&r.rect.h!==f)&&t.dispatch({type:"resizeInstance",payload:{instanceId:s.instanceId,w:v?p:r.rect.w,h:y?f:r.rect.h}}),(m&&r.rect.x!==l||I&&r.rect.y!==u)&&t.dispatch({type:"moveInstance",payload:{instanceId:s.instanceId,x:m?l:r.rect.x,y:I?u:r.rect.y}});else{const e={};w&&(e.widthMode=w.mode,e.width=w.value),x&&(e.heightMode=x.mode,e.height=x.value),m&&(e.x=l),I&&(e.y=u);const n=r.layoutBox;let o=!1;n?(void 0!==e.x&&e.x!==n.x&&(o=!0),void 0!==e.y&&e.y!==n.y&&(o=!0),void 0!==e.width&&e.width!==n.width&&(o=!0),void 0!==e.height&&e.height!==n.height&&(o=!0),void 0!==e.widthMode&&e.widthMode!==n.widthMode&&(o=!0),void 0!==e.heightMode&&e.heightMode!==n.heightMode&&(o=!0)):o=Object.keys(e).length>0,o&&t.dispatch({type:"updateLayoutBox",payload:{instanceId:s.instanceId,patch:e}})}if(("container"===s.placement||"slot"===s.placement)&&(null!==s.startSize||k)){const e=s.startSize,n={};v?n.width=Xn(null==e?void 0:e.width,p,g?g.w:null):(null==e?void 0:e.width)&&(n.width=JSON.parse(JSON.stringify(e.width))),y?n.height=Xn(null==e?void 0:e.height,f,g?g.h:null):(null==e?void 0:e.height)&&(n.height=JSON.parse(JSON.stringify(e.height)));const o=r.size;JSON.stringify(o)!==JSON.stringify(n)&&t.dispatch({type:"setInstanceSize",payload:{instanceId:s.instanceId,size:n}})}return}if("pending"===r.status&&r.startPt){const n=e.x-r.startPt.x,o=e.y-r.startPt.y;n*n+o*o>=9&&(r.status="active",t.beginBatch())}if("active"===r.status&&r.startPt){const a=e.x-r.startPt.x,s=e.y-r.startPt.y,d=(null==(n=i.getRoot)?void 0:n.call(i))??null,l=d instanceof HTMLElement?d:null,u=t.document.document.instances,p=null!==l&&u.length<=50,f=(e,n)=>p?_n(e,l,t.viewport)??n:n,h=[];for(const[e,n]of r.startRects){const o=t.document.getInstance(e);if(!o)continue;const i=f(e,o.rect);h.push({x:n.x+a,y:n.y+s,w:i.w,h:i.h})}const g=[],v=new Set(r.startRects.keys());for(const e of u)v.has(e.instanceId)||g.push(f(e.instanceId,e.rect));const y=t.document.document.layout,m=!1!==t.effectiveBehavior.value.snap,I=(null==(o=y.guides)?void 0:o.items)??[],w=[],x=[];for(const e of I)"x"===e.axis?w.push(e.position):x.push(e.position);const b=m?Pn({draggedRects:h,otherRects:g,canvasSize:{w:t.measuredCanvasSize.value.w,h:t.measuredCanvasSize.value.h},manualGuides:w.length||x.length?{x:w,y:x}:void 0}):{dx:0,dy:0,lines:[]};c.value=b.lines;const k=a+b.dx,S=s+b.dy;for(const[e,n]of r.startRects)t.document.getInstance(e)&&t.dispatch({type:"moveInstance",payload:{instanceId:e,x:n.x+k,y:n.y+S}});return}a.active&&(a.end={...e})},handlePointerUp(){if("active"===s.status){const e="slot"===s.placement||"container"===s.placement?"resize-slot-child":"resize";return t.endBatch(e),void m()}if("active"===r.status)return t.endBatch("drag"),void y();if("pending"===r.status)return r.deferredClickSelect&&t.dispatch({type:"select",payload:{instanceId:r.deferredClickSelect}}),void y();if(!a.active)return;const e=f.value,n=t.document.document.instances;if(e&&(e.w>0||e.h>0)){const o=Un(An(e,n),n);if(a.additive){const e=Un(a.priorSelection,n),i=Array.from(new Set([...e,...o]));t.dispatch({type:"selectAll",payload:{instanceIds:i}})}else o.length>0&&t.dispatch({type:"selectAll",payload:{instanceIds:o}})}v()},cancelMarquee(){v()},cancelDrag(){"active"===r.status&&t.endBatch("drag-cancel"),y()},handleResizeStart(e,n,o){var a,r,c,d;const l=t.document.getInstance(e);if(!l)return{startTracking:!1};if(!0===(l.lockSize??l.locked))return{startTracking:!1};if(l.hidden)return{startTracking:!1};if(!t.effectiveBehavior.value.resizable)return{startTracking:!1};const u="slot"===l.placement||"container"===l.placement,p=Kn(t,e);if("split"===p)return{startTracking:!1};if(("flex"===p||"grid"===p)&&!jn.includes(n))return{startTracking:!1};s.status="active",s.handle=n,s.startPt={...o};const f=_n(e,(null==(a=i.getRoot)?void 0:a.call(i))??null,t.viewport);s.startRect=f??{...l.rect},s.instanceId=e,s.placement=u?"container":"canvas",s.parentLayoutMode=p,s.startLayoutBox=l.layoutBox?JSON.parse(JSON.stringify(l.layoutBox)):{x:l.rect.x,y:l.rect.y,width:l.rect.w,height:l.rect.h,widthMode:"px",heightMode:"px",overflow:"hidden"},s.startSize=u&&l.size?JSON.parse(JSON.stringify(l.size)):null;const h=l.parentId,g=l.slot,v=(null==(r=i.getRoot)?void 0:r.call(i))??null;let y=h?Nn(h,g,v):null;if(h&&(!y||0===y.width&&0===y.height)){const n=Fn(v,`[data-instance-id="${e.replace(/["\\]/g,e=>`\\${e}`)}"]`),t=n instanceof HTMLElement?n.parentElement:null;if(t){const e=t.getBoundingClientRect();(e.width>0||e.height>0)&&(y=e)}}if(y){const e=t.viewport.scale.value||1;s.startOutletCanvasSize={w:y.width/e,h:y.height/e}}else if(void 0===h)s.startOutletCanvasSize={w:t.measuredCanvasSize.value.w,h:t.measuredCanvasSize.value.h};else{const n=s.startLayoutBox.widthMode,t=s.startLayoutBox.heightMode,o="percent"===n||"percent"===t;o&&console.debug("[hc-canvas/interaction] resize: 父 outlet 找不到,percent 模式将退化到 px。",{instanceId:e,parentId:h,slot:g});const i=s.startSize,a="percent"===(null==(c=null==i?void 0:i.width)?void 0:c.mode)||"percent"===(null==(d=null==i?void 0:i.height)?void 0:d.mode);!o&&a&&console.debug("[hc-canvas/interaction] slot child resize: 父 outlet 找不到,percent 模式将退化到 px。",{instanceId:e,parentId:h,slot:g}),s.startOutletCanvasSize=null}return t.beginBatch(),{startTracking:!0}},cancelResize(){if("active"===s.status){const e="slot"===s.placement||"container"===s.placement?"resize-slot-child-cancel":"resize-cancel";t.endBatch(e)}m()}}}function Gn(e,n){return{ok:!1,reason:e,message:n}}function Wn(e,n,t,o={}){const i=new Map;for(const n of e)i.set(n.instanceId,n);const a=i.get(n);if(!a)return Gn("instance-not-exists",`实例 "${n}" 不存在,无法 reparent`);const r=null===t.parentId||void 0===t.parentId?void 0:t.parentId;if(r===n)return Gn("self-parent",`parentId 不能等于自身 "${n}"`);if(void 0!==r){const e=i.get(r);if(!e)return Gn("parent-not-exists",`目标 parentId "${r}" 不存在`);const t=new Set;let o=e.parentId;for(;void 0!==o&&!t.has(o);){if(t.add(o),o===n)return Gn("cycle",`目标 parent "${r}" 是 "${n}" 的后代,会循环`);const e=i.get(o);o=null==e?void 0:e.parentId}}if(void 0===r)return{ok:!0};const s=o.resolveContract;if(!s)return{ok:!0};const c=i.get(r),d=s(c.componentVersionKey);if(!d)return{ok:!0};const l=d.slotsDecl??[];if(0===l.length)return Gn("parent-not-layout",`父组件 "${c.componentId}" 不是布局组件(slotsDecl 空)`);const u=void 0===t.slot||""===t.slot||"default"===t.slot?je:t.slot,p=(f=u,l.find(e=>e.name===f));var f;if(!p)return Gn("slot-not-exists",`slot "${u}" 不在父 "${c.componentId}" 的 slotsDecl`);if(p.accepts&&p.accepts.length>0&&!p.accepts.includes(a.componentId))return Gn("accepts-violation",`slot "${u}" 不允许 componentId "${a.componentId}"(accepts: ${p.accepts.join(", ")})`);if(!0!==p.multiple){const t=e.filter(e=>e.instanceId!==n&&e.parentId===r&&Ne(e)===u);if(t.length>0)return Gn("slot-multiple-violated",`slot "${u}" 不允许多个子实例(已有 "${t[0].instanceId}")`)}if("number"==typeof p.maxChildren&&Number.isFinite(p.maxChildren)&&p.maxChildren>=1){const t=e.filter(e=>e.instanceId!==n&&e.parentId===r&&Ne(e)===u);if(t.length+1>p.maxChildren)return Gn("max-children-exceeded",`slot "${u}" 最多接受 ${p.maxChildren} 个子(已有 ${t.length} 个)`)}return{ok:!0}}function Qn(e){const n=new Set(e.map(e=>e.instanceId)),t=new Map;for(const n of e)t.set(n.instanceId,et(n));const o=[],i=new Map;e.forEach((e,a)=>{const r={inst:e,node:t.get(e.instanceId),originalIndex:a},s=e.parentId;if(s){if(!n.has(s))return console.warn(`[hc-canvas/instance-tree] instance "${e.instanceId}" parentId="${s}" 不存在,降级当顶层`),void o.push(r);i.has(s)||i.set(s,[]),i.get(s).push(r)}else o.push(r)});for(const[e,n]of i){const o=t.get(e);o&&(o.children=Zn(n).map(e=>e.node))}return o.slice().sort((e,n)=>{const t=(n.inst.zIndex??0)-(e.inst.zIndex??0);return 0!==t?t:e.originalIndex-n.originalIndex}).map(e=>e.node)}function Zn(e){const n=new Map;for(const t of e){const e=t.inst.slot??"default";let o=n.get(e);o||(o={firstIndex:t.originalIndex,entries:[]},n.set(e,o)),o.entries.push(t)}return Array.from(n.values()).sort((e,n)=>e.firstIndex-n.firstIndex).flatMap(e=>e.entries.slice().sort((e,n)=>e.originalIndex-n.originalIndex))}function et(e){const n={instanceId:e.instanceId,componentId:e.componentId,componentVersionKey:e.componentVersionKey,kind:"visual",label:e.alias??e.instanceId};return void 0!==e.locked&&(n.locked=e.locked),void 0!==e.lockPosition&&(n.lockPosition=e.lockPosition),void 0!==e.lockSize&&(n.lockSize=e.lockSize),void 0!==e.hidden&&(n.hidden=e.hidden),n}function nt(e,n){for(const t of e){if(t.instanceId===n)return[t];if(t.children&&t.children.length>0){const e=nt(t.children,n);if(e.length>0)return[t,...e]}}return[]}function tt(e,n){const t=new Map;for(const n of e)t.set(n.instanceId,n);const o=t.get(n);if(!o)return[];const i=[o];let a=o;const r=e.length;for(;a&&a.parentId;){if(i.length>r){console.warn(`[hc-canvas/instance-tree] breadcrumb for "${n}" exceeds depth ${r},疑似环,截断`);break}const e=t.get(a.parentId);if(!e)break;i.unshift(e),a=e}return i}function ot(e,n,t){const o=n||void 0;return e.filter(e=>(e.parentId||void 0)===o&&e.slot===t).map((e,n)=>({inst:e,originalIndex:n})).sort((e,n)=>{const t=(n.inst.zIndex??0)-(e.inst.zIndex??0);return 0!==t?t:e.originalIndex-n.originalIndex}).map(e=>e.inst)}const it=40;function at(e){if(0===e.length)return null;let n=1/0,t=1/0,o=-1/0,i=-1/0;for(const a of e)a.x<n&&(n=a.x),a.y<t&&(t=a.y),a.x+a.w>o&&(o=a.x+a.w),a.y+a.h>i&&(i=a.y+a.h);return{x:n,y:t,w:o-n,h:i-t}}function rt(e){return at(e.map(e=>e.rect))}function st(e,n){if(0===n.length)return null;const t=new Set(n),o=[];for(const n of e)t.has(n.instanceId)&&o.push(n.rect);return at(o)}function ct(e,n,t){const o=(null==t?void 0:t.padding)??40,i=Math.max(1,n.w-2*o),a=Math.max(1,n.h-2*o),r=Math.max(1,e.w),s=Math.max(1,e.h);let c=Math.min(i/r,a/s);void 0!==(null==t?void 0:t.maxScale)&&(c=Math.min(c,t.maxScale)),void 0!==(null==t?void 0:t.minScale)&&(c=Math.max(c,t.minScale));const d=e.x+e.w/2,l=e.y+e.h/2;return{scale:c,panX:n.w/2-d*c,panY:n.h/2-l*c}}function dt(e,n){const t=e.scale||1;return{x:-e.panX/t+0,y:-e.panY/t+0,w:n.w/t,h:n.h/t}}function lt(e){const n=[];(e.metaKey||e.ctrlKey)&&n.push("mod"),e.shiftKey&&n.push("shift"),e.altKey&&n.push("alt");let t=e.key;return t="Meta"===t||"Control"===t?"mod":" "===t||"Space"===e.code?"space":(t.length,t.toLowerCase()),n[n.length-1]===t||n.push(t),n.join("+")}function ut(e){if(!(e&&e instanceof HTMLElement))return!1;const n=e.tagName;return"INPUT"===n||"TEXTAREA"===n||"SELECT"===n||!!e.isContentEditable}function pt(e,n){const t=lt(n);for(const n of e.keys)if(ft(n)===t)return!0;return!1}function ft(e){return e.split("+").map(e=>e.trim().toLowerCase()).join("+")}function ht(){return[{id:"undo",keys:["mod+z"],command:"undo",when:"notEditingText"},{id:"redo",keys:["mod+shift+z","mod+y"],command:"redo",when:"notEditingText"},{id:"deleteSelection",keys:["delete","backspace"],command:"deleteSelection",when:"hasSelection"},{id:"duplicateSelection",keys:["mod+d"],command:"duplicateSelection",when:"hasSelection"},{id:"fitToSelectionOrContent",keys:["f"],command:"fitToSelectionOrContent",when:"notEditingText"},{id:"zoom100",keys:["1"],command:"zoom100",when:"notEditingText"},{id:"resetViewport",keys:["0"],command:"resetViewport",when:"notEditingText"},{id:"zoomIn",keys:["+","="],command:"zoomIn",when:"notEditingText"},{id:"zoomOut",keys:["-"],command:"zoomOut",when:"notEditingText"},{id:"nudgeLeft",keys:["arrowleft"],command:"nudgeSelection",payload:{dx:-1,dy:0},when:"hasSelection"},{id:"nudgeRight",keys:["arrowright"],command:"nudgeSelection",payload:{dx:1,dy:0},when:"hasSelection"},{id:"nudgeUp",keys:["arrowup"],command:"nudgeSelection",payload:{dx:0,dy:-1},when:"hasSelection"},{id:"nudgeDown",keys:["arrowdown"],command:"nudgeSelection",payload:{dx:0,dy:1},when:"hasSelection"},{id:"nudgeLeftLarge",keys:["shift+arrowleft"],command:"nudgeSelectionLarge",payload:{dx:-1,dy:0},when:"hasSelection"},{id:"nudgeRightLarge",keys:["shift+arrowright"],command:"nudgeSelectionLarge",payload:{dx:1,dy:0},when:"hasSelection"},{id:"nudgeUpLarge",keys:["shift+arrowup"],command:"nudgeSelectionLarge",payload:{dx:0,dy:-1},when:"hasSelection"},{id:"nudgeDownLarge",keys:["shift+arrowdown"],command:"nudgeSelectionLarge",payload:{dx:0,dy:1},when:"hasSelection"},{id:"cancelInteraction",keys:["escape"],command:"cancelInteraction",when:"notEditingText"}]}function gt(e,t){const a=Bn(e,t.recorder);function r(n){const o=t.getStageEl();if(!o)return console.warn("[hc-canvas/handle] clientToCanvasPoint called before stage mounted; falling back to viewport.toCanvasPoint(raw clientPt). 结果可能偏移。"),e.viewport.toCanvasPoint(n);const i=o.getBoundingClientRect();return e.viewport.toCanvasPoint({x:n.x-i.left,y:n.y-i.top})}function s(n,t){const o=e.document.getInstance(n);if(!o)return null;const i=(null==t?void 0:t.newInstanceId)??function(e){var n;const t="undefined"!=typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;return`${e}_${(null==(n=null==t?void 0:t.randomUUID)?void 0:n.call(t).replace(/-/g,"").slice(0,8))??Math.random().toString(36).slice(2,10)}`}(o.componentId);return e.dispatch({type:"duplicateInstance",payload:{instanceId:n,newInstanceId:i,...void 0!==(null==t?void 0:t.offset)?{offset:t.offset}:{}}}),e.document.getInstance(i)?i:null}function c(){return JSON.parse(JSON.stringify(e.document.document.layout))}function d(){return Qn(e.document.document.instances)}function l(n,o){const i=e.document.getInstance(n);if(!i)return console.warn(`[hc-canvas/handle] ${o}: instance "${n}" 不存在`),!1;const a=t.getStageEl();if(!a)return console.warn(`[hc-canvas/handle] ${o}: stage 未挂载,跳过滚动(${n})`),!1;const r=_n(n,a,e.viewport),s=r&&(r.w>0||r.h>0)?r:{x:i.rect.x,y:i.rect.y,w:i.rect.w,h:i.rect.h},c=a.getBoundingClientRect(),d=e.viewport.scale.value,l=c.width/2-(s.x+s.w/2)*d,u=c.height/2-(s.y+s.h/2)*d;return e.viewport.setPan(l,u),!0}const u=o(null);let p=0;function f(e){var n;return"undefined"!=typeof globalThis&&(null==(n=globalThis.CSS)?void 0:n.escape)?globalThis.CSS.escape(e):e.replace(/["\\]/g,e=>`\\${e}`)}function h(){const e=t.getStageEl();if(!e)return null;const n=e.getBoundingClientRect();return{w:n.width,h:n.height}}function g(){return{scale:e.viewport.scale.value,panX:e.viewport.panX.value,panY:e.viewport.panY.value}}function v(){return rt(e.document.document.instances)}function y(){return st(e.document.document.instances,e.selection.selectedIds.value)}function m(n,t){const o=h();if(!o)return void e.viewport.setScale(n);const i=g();let a;if(null==t?void 0:t.center)a=t.center;else{const e=dt(i,o);a={x:e.x+e.w/2,y:e.y+e.h/2}}const r=a.x*i.scale+i.panX,s=a.y*i.scale+i.panY,c=r-a.x*n,d=s-a.y*n;e.viewport.setScale(n),e.viewport.setPan(c,d)}function I(n,t){m(e.viewport.scale.value+n,t)}function w(){e.viewport.resetView()}function x(n,t){const o=h();if(!o)return void console.warn("[hc-canvas/handle] scrollToRect: stage 未挂载,跳过");const i=ct(n,o,t);e.viewport.setScale(i.scale),e.viewport.setPan(i.panX,i.panY)}function b(e){const n=v();n&&x(n,e)}function k(e){const n=y();n&&x(n,e)}const S=Object.freeze([{id:"undo",keys:["mod+z"],command:"undo",when:"notEditingText"},{id:"redo",keys:["mod+shift+z","mod+y"],command:"redo",when:"notEditingText"},{id:"deleteSelection",keys:["delete","backspace"],command:"deleteSelection",when:"hasSelection"},{id:"duplicateSelection",keys:["mod+d"],command:"duplicateSelection",when:"hasSelection"},{id:"fitToSelectionOrContent",keys:["f"],command:"fitToSelectionOrContent",when:"notEditingText"},{id:"zoom100",keys:["1"],command:"zoom100",when:"notEditingText"},{id:"resetViewport",keys:["0"],command:"resetViewport",when:"notEditingText"},{id:"zoomIn",keys:["+","="],command:"zoomIn",when:"notEditingText"},{id:"zoomOut",keys:["-"],command:"zoomOut",when:"notEditingText"},{id:"nudgeLeft",keys:["arrowleft"],command:"nudgeSelection",payload:{dx:-1,dy:0},when:"hasSelection"},{id:"nudgeRight",keys:["arrowright"],command:"nudgeSelection",payload:{dx:1,dy:0},when:"hasSelection"},{id:"nudgeUp",keys:["arrowup"],command:"nudgeSelection",payload:{dx:0,dy:-1},when:"hasSelection"},{id:"nudgeDown",keys:["arrowdown"],command:"nudgeSelection",payload:{dx:0,dy:1},when:"hasSelection"},{id:"nudgeLeftLarge",keys:["shift+arrowleft"],command:"nudgeSelectionLarge",payload:{dx:-1,dy:0},when:"hasSelection"},{id:"nudgeRightLarge",keys:["shift+arrowright"],command:"nudgeSelectionLarge",payload:{dx:1,dy:0},when:"hasSelection"},{id:"nudgeUpLarge",keys:["shift+arrowup"],command:"nudgeSelectionLarge",payload:{dx:0,dy:-1},when:"hasSelection"},{id:"nudgeDownLarge",keys:["shift+arrowdown"],command:"nudgeSelectionLarge",payload:{dx:0,dy:1},when:"hasSelection"},{id:"cancelInteraction",keys:["escape"],command:"cancelInteraction",when:"notEditingText"}]);function M(){const n=e.selection.selectedIds.value;if(0===n.length)return!1;for(const t of n){const n=e.document.getInstance(t);if(n&&!0!==(n.lockPosition??n.locked))return!0}return!1}function T(n,t,o){const i=o?10:1,a=e.selection.selectedIds.value;if(0===a.length)return;const r=!e.isBatching.value;r&&e.beginBatch();try{for(const o of a){const a=e.document.getInstance(o);if(!a||!0===(a.lockPosition??a.locked))continue;const r=Kn(e,o);Jn(r)?e.dispatch({type:"moveInstance",payload:{instanceId:o,x:a.rect.x+n*i,y:a.rect.y+t*i}}):"undefined"!=typeof console&&"function"==typeof console.debug&&console.debug("[hc-canvas/handle] executeNudge: 拒绝 layout-managed 子 nudge",{instanceId:o,parentLayoutMode:r})}}finally{r&&e.endBatch(o?"arrow-move-large":"arrow-move")}}function z(n){const t=[...e.selection.selectedIds.value];if(0===t.length)return;const o=!e.isBatching.value;o&&e.beginBatch();try{for(const o of t)e.dispatch({type:"setInstanceLocked",payload:{instanceId:o,locked:n}})}finally{o&&e.endBatch(n?"lock-selection":"unlock-selection")}}function B(n){const t=e.selection.selectedIds.value;if(0===t.length)return;const o=e.document.document.instances;if(0===o.length)return;const i=o.map((e,n)=>({inst:e,origIdx:n})).sort((e,n)=>{const t=e.inst.zIndex??0,o=n.inst.zIndex??0;return t!==o?t-o:e.origIdx-n.origIdx}).map(e=>e.inst),a=new Set(t),r=[];for(let e=0;e<i.length;e++)a.has(i[e].instanceId)&&r.push(e);if(0===r.length)return;if(r.length===i.length)return;const s=r.map(e=>i[e]),c=i.filter(e=>!a.has(e.instanceId));let d;if("toFront"===n)d=[...c,...s];else if("toBack"===n)d=[...s,...c];else if("forward"===n){let e=r[r.length-1]+1;for(;e<i.length&&a.has(i[e].instanceId);)e++;if(e>=i.length)return;const n=i[e],t=c.indexOf(n);d=[...c.slice(0,t+1),...s,...c.slice(t+1)]}else{let e=r[0]-1;for(;e>=0&&a.has(i[e].instanceId);)e--;if(e<0)return;const n=i[e],t=c.indexOf(n);d=[...c.slice(0,t),...s,...c.slice(t)]}const l=[];for(let e=0;e<d.length;e++){const n=d[e];(n.zIndex??0)!==e&&l.push({id:n.instanceId,zIndex:e})}if(0===l.length)return;const u=!e.isBatching.value;u&&e.beginBatch();try{for(const n of l)e.dispatch({type:"updateInstance",payload:{instanceId:n.id,patch:{zIndex:n.zIndex}}})}finally{u&&e.endBatch(`z-order-${n}`)}}const L={undo:{execute:()=>a.undo(),canExecute:()=>a.canUndo.value},redo:{execute:()=>a.redo(),canExecute:()=>a.canRedo.value},deleteSelection:{execute:function(){const n=[...e.selection.selectedIds.value];if(0===n.length)return;const t=!e.isBatching.value;t&&e.beginBatch();try{for(const t of n)e.dispatch({type:"removeInstance",payload:{instanceId:t}})}finally{t&&e.endBatch("delete-selection")}},canExecute:()=>e.selection.selectedIds.value.length>0},duplicateSelection:{execute:function(){const n=[...e.selection.selectedIds.value];if(0===n.length)return;const t=[],o=!e.isBatching.value;o&&e.beginBatch();try{for(const e of n){const n=s(e);n&&t.push(n)}t.length>0&&e.dispatch({type:"selectAll",payload:{instanceIds:t}})}finally{o&&e.endBatch("duplicate-selection")}},canExecute:()=>e.selection.selectedIds.value.length>0},clearSelection:{execute:()=>e.dispatch({type:"clearSelection"}),canExecute:()=>e.selection.selectedIds.value.length>0},cancelInteraction:{execute:()=>e.dispatch({type:"clearSelection"}),canExecute:()=>!0},zoomIn:{execute:()=>I(.1),canExecute:()=>!0},zoomOut:{execute:()=>I(-.1),canExecute:()=>!0},zoom100:{execute:()=>m(1),canExecute:()=>!0},resetViewport:{execute:()=>w(),canExecute:()=>!0},fitToContent:{execute:()=>b(),canExecute:()=>null!==v()},fitToSelection:{execute:()=>k(),canExecute:()=>null!==y()},fitToSelectionOrContent:{execute:()=>{y()?k():b()},canExecute:()=>null!==y()||null!==v()},nudgeSelection:{execute:e=>{const n=e??{dx:0,dy:0};T(n.dx,n.dy,!1)},canExecute:M},nudgeSelectionLarge:{execute:e=>{const n=e??{dx:0,dy:0};T(n.dx,n.dy,!0)},canExecute:M},lockSelection:{execute:()=>z(!0),canExecute:()=>e.selection.selectedIds.value.length>0},unlockSelection:{execute:()=>z(!1),canExecute:()=>e.selection.selectedIds.value.length>0},bringForward:{execute:()=>B("forward"),canExecute:()=>e.selection.selectedIds.value.length>0},sendBackward:{execute:()=>B("backward"),canExecute:()=>e.selection.selectedIds.value.length>0},bringToFront:{execute:()=>B("toFront"),canExecute:()=>e.selection.selectedIds.value.length>0},sendToBack:{execute:()=>B("toBack"),canExecute:()=>e.selection.selectedIds.value.length>0},toggleGrid:{execute:function(){var n;const t=null==(n=e.document.document.layout.guides)?void 0:n.grid;D(!(null==t?void 0:t.visible))},canExecute:()=>!0},toggleRuler:{execute:function(){var n;const t=null==(n=e.document.document.layout.guides)?void 0:n.ruler;O(!(null==t?void 0:t.visible))},canExecute:()=>!0}};function P(n,t){const o=null===t?null:JSON.parse(JSON.stringify(t));e.dispatch({type:"setComponentOverride",payload:{instanceId:n,override:o}})}function C(n,t){const o=n??"notEditingText";return"always"===o||("notEditingText"===o?!ut(t.target):"design"===o?!ut(t.target)&&!1!==e.effectiveBehavior.value.draggable:"hasSelection"===o&&!ut(t.target)&&e.selection.selectedIds.value.length>0)}function $(){return e.document.document.layout.guides??{}}function E(n){e.dispatch({type:"updateLayout",payload:{patch:{guides:n}}})}function O(e){const n=$();E({...n,ruler:{...n.ruler??{},visible:e}})}function D(e){const n=$();E({...n,grid:{...n.grid??{},visible:e}})}const R=n(()=>{const n=e.selection.selectedIds.value;if(0===n.length)return[];const t=new Set(n);return e.document.document.instances.filter(e=>t.has(e.instanceId))}),A=e.selection.selectedIds,j=i(A),F=i(e.isBatching);let N=null,q=null;return{dispatch:n=>e.dispatch(n),beginBatch:()=>e.beginBatch(),endBatch:n=>e.endBatch(n),isBatching:F,getSnapshot:()=>JSON.parse(JSON.stringify(e.document.document)),selectedIds:j,selectedInstances:R,viewport:e.viewport,clientToCanvasPoint:r,getInstanceAtClientPoint:function(n){const o=t.getStageEl();if(!o)return null;const i=Dn(r(n),e.document.document.instances,n=>_n(n,o,e.viewport));return i?e.document.getInstance(i)??null:null},getDropTarget:function(n,o,i){var a;const r=o??(null==(a=t.getStageEl)?void 0:a.call(t))??("undefined"!=typeof document&&"function"==typeof document.querySelectorAll?document:null);if(!r)return null;const s=void 0!==(null==i?void 0:i.excludeInstanceId),c=s?`[data-instance-id="${f(i.excludeInstanceId)}"]`:null;let d=c?r.querySelector(c):null;if(!d&&s&&r instanceof Element){const e=r.closest("[data-hc-canvas-designer]");e&&e!==r&&(d=e.querySelector(c))}let l=r.querySelectorAll("[data-hc-slot]");if(0===l.length&&s&&r instanceof Element){const e=r.closest("[data-hc-canvas-designer]");e&&e!==r&&(l=e.querySelectorAll("[data-hc-slot]"))}let u=null;for(const e of l){if(!(e instanceof HTMLElement))continue;if(d&&d.contains(e))continue;const t=e.getBoundingClientRect();if(0===t.width&&0===t.height)continue;if(n.x<t.left||n.x>t.right)continue;if(n.y<t.top||n.y>t.bottom)continue;let o=0,i=e;for(;i;)o++,i=i.parentElement;(!u||o>u.depth)&&(u={el:e,depth:o})}if(!u)return null;const p=u.el,h=p.closest("[data-instance-id]");if(!h)return null;const g=h.getAttribute("data-instance-id");return g&&e.document.getInstance(g)?{parentId:g,slot:p.getAttribute("data-hc-slot")||"default",outletEl:p}:null},duplicateInstance:s,undo:a.undo,redo:a.redo,canUndo:a.canUndo,canRedo:a.canRedo,undoStackSize:a.undoStackSize,redoStackSize:a.redoStackSize,clearHistory:a.clear,getLayoutConfig:c,updateCanvasSize:function(n){const t={...c().canvas,...n};e.dispatch({type:"updateLayout",payload:{patch:{canvas:t}}})},updateCanvasBackground:function(n){if(null===n)return void e.dispatch({type:"updateLayout",payload:{patch:{background:void 0}}});const t={...c().background??{},...n};e.dispatch({type:"updateLayout",payload:{patch:{background:t}}})},updateBehavior:function(n){const t={...c().behavior??{},...n};e.dispatch({type:"updateLayout",payload:{patch:{behavior:t}}})},setInteractionOptions:function(n){e.setInteractionOptions(n)},getEffectiveBehavior:function(){return{...e.effectiveBehavior.value}},setRootLayout:function(n){let t;if(null===n)t=null;else if("string"==typeof n)switch(n){case"free":t={mode:"free"};break;case"none":t={mode:"none"};break;case"split":t={mode:"split",direction:"horizontal",ratios:[.5,.5]};break;case"grid":t={mode:"grid",columns:[{mode:"fr",value:1},{mode:"fr",value:1}],rows:[{mode:"fr",value:1},{mode:"fr",value:1}]};break;case"flex":t={mode:"flex",direction:"row"};break;default:return void console.warn(`[hc-canvas/handle] setRootLayout: 未知 mode "${n}",忽略`)}else t=n;e.dispatch({type:"setRootLayout",payload:{rootLayout:t}})},getInstanceTree:d,getInstanceList:function(){return e.document.document.instances.map(e=>JSON.parse(JSON.stringify(e)))},getInstance:function(n){const t=e.document.getInstance(n);return t?JSON.parse(JSON.stringify(t)):null},getSelectedPath:function(){const n=e.selection.primaryId.value;return n?nt(d(),n):[]},getBreadcrumb:function(n){return tt(e.document.document.instances,n).map(e=>JSON.parse(JSON.stringify(e)))},focusInstance:function(n){e.document.getInstance(n)?(e.dispatch({type:"select",payload:{instanceId:n}}),l(n,"focusInstance")):console.warn(`[hc-canvas/handle] focusInstance: instance "${n}" 不存在`)},scrollToInstance:function(e){l(e,"scrollToInstance")},moveInstanceInTree:function(n,o){var i,a,r;const s=Wn(e.document.document.instances,n,o,{resolveContract:t.resolveContract});if(!s.ok)return console.warn(`[hc-canvas/handle] moveInstanceInTree 守门拒绝(${s.reason}): ${s.message}`),void function(e,n,t,o){p++,u.value={instanceId:e,target:{...n},reason:t,message:o,token:p}}(n,o,s.reason,s.message??`reparent rejected: ${s.reason}`);const c=e.document.getInstance(n),d=null===o.parentId?void 0:o.parentId,l=(c.parentId||void 0)!==(d||void 0),f=c.slot!==o.slot,h={};if(l&&(h.parentId=d),f&&(h.slot=o.slot),l){const n=void 0===d?"canvas":"container";c.placement!==n&&(h.placement=n);const t=e.document.document.layout,o=void 0===d?(null==(i=null==t?void 0:t.rootLayout)?void 0:i.mode)??"free":(null==(r=null==(a=e.document.getInstance(d))?void 0:a.containerLayout)?void 0:r.mode)??"none";if(c.layoutBox)if("container"!==n||"flex"!==o&&"split"!==o&&"grid"!==o){if("canvas"===n){const e="fill"===c.layoutBox.widthMode?"px":c.layoutBox.widthMode,n="fill"===c.layoutBox.heightMode?"px":c.layoutBox.heightMode;e===c.layoutBox.widthMode&&n===c.layoutBox.heightMode||(h.layoutBox={...c.layoutBox,widthMode:e,heightMode:n})}}else h.layoutBox={...c.layoutBox,x:0,y:0,widthMode:"fill",heightMode:"fill"},h.rect={x:0,y:0,w:c.rect.w,h:c.rect.h};if("container"===n&&"grid"===o){const e=c.layoutItem??{};void 0!==e.row&&void 0!==e.column||(h.layoutItem={...e,row:e.row??0,column:e.column??0})}}const g=[];if(void 0!==o.index){const t=ot(e.document.document.instances,d,o.slot).filter(e=>e.instanceId!==n),i=Math.max(0,Math.min(o.index,t.length));t.splice(i,0,c),t.forEach((e,n)=>{const o=t.length-1-n;(e.zIndex??0)!==o&&g.push({id:e.instanceId,zIndex:o})})}if(0===Object.keys(h).length&&0===g.length)return;const v=!e.isBatching.value;v&&e.beginBatch();try{Object.keys(h).length>0&&e.dispatch({type:"updateInstance",payload:{instanceId:n,patch:h}});for(const n of g)e.dispatch({type:"updateInstance",payload:{instanceId:n.id,patch:{zIndex:n.zIndex}}})}finally{v&&e.endBatch("moveInstanceInTree")}},canReparent:function(n,o){return Wn(e.document.document.instances,n,o,{resolveContract:t.resolveContract})},cannotReparentEvent:i(u),cannotDragLayoutManagedChildEvent:e.cannotDragLayoutManagedChildEvent,resolveAsset:function(n){return e.resolveAsset(n)},getViewportState:g,getVisibleBounds:function(){const e=h();return e?dt(g(),e):{x:0,y:0,w:0,h:0}},getCanvasBounds:function(){const n=e.measuredCanvasSize.value;return{x:0,y:0,w:n.w,h:n.h}},getContentBounds:v,getSelectionBounds:y,getInstanceBounds:function(n){const t=e.document.getInstance(n);return t?{...t.rect}:null},panBy:function(n,t){e.viewport.setPan(e.viewport.panX.value+n,e.viewport.panY.value+t)},panTo:function(n,t){e.viewport.setPan(n,t)},zoomTo:m,zoomBy:I,zoomToPoint:function(n,o){const i=t.getStageEl();if(!i)return void console.warn("[hc-canvas/handle] zoomToPoint: stage 未挂载,跳过");const a=i.getBoundingClientRect(),r=o.x-a.left,s=o.y-a.top,c=g(),d=r-(r-c.panX)/c.scale*n,l=s-(s-c.panY)/c.scale*n;e.viewport.setScale(n),e.viewport.setPan(d,l)},resetViewport:w,fitToContent:b,fitToSelection:k,scrollToRect:x,toolMode:e.toolMode,getToolMode:function(){return e.toolMode.value},setToolMode:function(n){e.setToolMode(n)},setTemporaryToolMode:function(n){e.setTemporaryToolMode(n)},getDefaultShortcuts:function(){return[{id:"undo",keys:["mod+z"],command:"undo",when:"notEditingText"},{id:"redo",keys:["mod+shift+z","mod+y"],command:"redo",when:"notEditingText"},{id:"deleteSelection",keys:["delete","backspace"],command:"deleteSelection",when:"hasSelection"},{id:"duplicateSelection",keys:["mod+d"],command:"duplicateSelection",when:"hasSelection"},{id:"fitToSelectionOrContent",keys:["f"],command:"fitToSelectionOrContent",when:"notEditingText"},{id:"zoom100",keys:["1"],command:"zoom100",when:"notEditingText"},{id:"resetViewport",keys:["0"],command:"resetViewport",when:"notEditingText"},{id:"zoomIn",keys:["+","="],command:"zoomIn",when:"notEditingText"},{id:"zoomOut",keys:["-"],command:"zoomOut",when:"notEditingText"},{id:"nudgeLeft",keys:["arrowleft"],command:"nudgeSelection",payload:{dx:-1,dy:0},when:"hasSelection"},{id:"nudgeRight",keys:["arrowright"],command:"nudgeSelection",payload:{dx:1,dy:0},when:"hasSelection"},{id:"nudgeUp",keys:["arrowup"],command:"nudgeSelection",payload:{dx:0,dy:-1},when:"hasSelection"},{id:"nudgeDown",keys:["arrowdown"],command:"nudgeSelection",payload:{dx:0,dy:1},when:"hasSelection"},{id:"nudgeLeftLarge",keys:["shift+arrowleft"],command:"nudgeSelectionLarge",payload:{dx:-1,dy:0},when:"hasSelection"},{id:"nudgeRightLarge",keys:["shift+arrowright"],command:"nudgeSelectionLarge",payload:{dx:1,dy:0},when:"hasSelection"},{id:"nudgeUpLarge",keys:["shift+arrowup"],command:"nudgeSelectionLarge",payload:{dx:0,dy:-1},when:"hasSelection"},{id:"nudgeDownLarge",keys:["shift+arrowdown"],command:"nudgeSelectionLarge",payload:{dx:0,dy:1},when:"hasSelection"},{id:"cancelInteraction",keys:["escape"],command:"cancelInteraction",when:"notEditingText"}]},executeShortcut:function(e){for(const n of S){if(!pt(n,e))continue;if(!C(n.when,e))continue;const t=L[n.command];return!!t&&!!t.canExecute()&&(t.execute(n.payload),!1!==n.preventDefault&&e.preventDefault(),!0)}return!1},executeCommand:function(e,n){const t=L[e];t?t.canExecute()&&t.execute(n):console.warn(`[hc-canvas/handle] executeCommand: 未知命令 "${e}"`)},canExecuteCommand:function(e){const n=L[e];return!!n&&n.canExecute()},getStaleComponentOverrides:function(){const n=e.document.document.componentOverrides??{},t=[];for(const o of e.document.document.instances){const e=n[o.instanceId];e&&e.baseVersionKey!==o.componentVersionKey&&t.push({instanceId:o.instanceId,baseVersionKey:e.baseVersionKey,currentVersionKey:o.componentVersionKey})}return t},setComponentOverride:P,discardComponentOverride:function(e){P(e,null)},getLayoutIssues:function(){return e.layoutIssues.value},setRulerVisible:O,setGridVisible:D,updateRulerConfig:function(e){const n=$();E({...n,ruler:{...n.ruler??{},...e}})},updateGridConfig:function(e){const n=$();E({...n,grid:{...n.grid??{},...e}})},addGuide:function(e){const n=$(),t=n.items??[],o=e.id??function(){var e;const n="undefined"!=typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;return`g_${(null==(e=null==n?void 0:n.randomUUID)?void 0:e.call(n).replace(/-/g,"").slice(0,8))??Math.random().toString(36).slice(2,10)}`}();if(t.some(e=>e.id===o))return console.warn(`[hc-canvas/handle] addGuide: id "${o}" 已存在,忽略`),o;const i={id:o,axis:e.axis,position:e.position};return void 0!==e.locked&&(i.locked=e.locked),void 0!==e.label&&(i.label=e.label),E({...n,items:[...t,i]}),o},removeGuide:function(e){const n=$(),t=n.items??[];t.some(n=>n.id===e)&&E({...n,items:t.filter(n=>n.id!==e)})},updateGuide:function(e,n){const t=$(),o=t.items??[],i=o.findIndex(n=>n.id===e);if(i<0)return void console.warn(`[hc-canvas/handle] updateGuide: id "${e}" 不存在,忽略`);const{id:a,...r}=n,s={...o[i],...r},c=[...o];c[i]=s,E({...t,items:c})},getGuides:function(){return($().items??[]).map(e=>({...e}))},clearGuides:function(){const e=$();e.items&&0!==e.items.length&&E({...e,items:[]})},getMouseCanvasPoint:function(){const n=e.mouseCanvasPoint.value;return n?{x:n.x,y:n.y}:null},getInstanceSize:function(n){const t=e.document.getInstance(n);if(t&&void 0!==t.size)return JSON.parse(JSON.stringify(t.size))},updateInstanceSize:function(n,t){e.dispatch({type:"setInstanceSize",payload:{instanceId:n,size:t}})},getContainerLayout:function(n){const t=e.document.getInstance(n);return t&&void 0!==t.containerLayout?JSON.parse(JSON.stringify(t.containerLayout)):null},updateContainerLayout:function(n,t){e.dispatch({type:"setContainerLayout",payload:{instanceId:n,containerLayout:t}})},getInstanceOutletRect:function(e,n){if("undefined"==typeof document||"function"!=typeof document.querySelector)return null;const t=n??"default",o=""===t?"default":t,i=`[data-instance-id="${f(e)}"]`,a=`[data-hc-slot="${f(o)}"]`,r=document.querySelector(`${i} ${a}`);return r&&r instanceof HTMLElement?r.getBoundingClientRect():null},getLayoutBox:function(n){const t=e.document.getInstance(n);if(t&&void 0!==t.layoutBox)return JSON.parse(JSON.stringify(t.layoutBox))},updateLayoutBox:function(n,t){e.dispatch({type:"updateLayoutBox",payload:{instanceId:n,patch:t}})},getLayoutItem:function(n){const t=e.document.getInstance(n);if(t&&void 0!==t.layoutItem)return JSON.parse(JSON.stringify(t.layoutItem))},updateLayoutItem:function(n,t){e.dispatch({type:"updateLayoutItem",payload:{instanceId:n,patch:t}})},getRotation:function(n){const t=e.document.getInstance(n);if(!t)return 0;const o=t.rotation;return"number"==typeof o&&Number.isFinite(o)?o:0},updateRotation:function(n,t){e.dispatch({type:"updateRotation",payload:{instanceId:n,value:t}})},setBindingMode:function(e){null==N||N.setMode(e)},getBindingMode:function(){return(null==N?void 0:N.getMode())??"off"},testBinding:function(e,n){return(null==N?void 0:N.testBinding(e,n))??[]},on:function(e,n){return N?N.on(e,n):()=>{}},attachBindingDelegate:function(e,n){N=e,null===e?q=null:arguments.length>=2&&(q=n??null)},invalidateDataSource:function(e){null==q||q.invalidate(e)},getDataSourceSnapshot:function(){return(null==q?void 0:q.getSnapshot())??{entries:[]}},startTracing:function(e){null==N||N.startTracing(e)},stopTracing:function(){return(null==N?void 0:N.stopTracing())??[]},getTraceBuffer:function(){return(null==N?void 0:N.getTraceBuffer())??[]},dispose:a.dispose}}const vt=Symbol("hc:canvas:reparent-bridge");function yt(e){return"string"==typeof e&&e.includes("@draft:")}function mt(e){if("string"!=typeof e||!e.includes("@"))return null;const n=e.indexOf("@"),t=e.slice(0,n),o=e.slice(n+1);if(!t)return null;if(o.startsWith("draft:")){const e=o.slice(6),n=e.indexOf(":");if(n<=0)return null;const i=e.slice(0,n),a=e.slice(n+1);return i&&a?{kind:"draft",componentId:t,pageId:i,baseVersion:a,baseVersionKey:`${t}@${a}`}:null}return o?{kind:"published",componentId:t,version:o}:null}function It(e){return"preview"===e||"runtime"===e?"runtime":"off"}const wt=(e=>{const n=e.__vccOpts||e;for(const[e,t]of[["__scopeId","data-v-825e0ee8"]])n[e]=t;return n})(s({__name:"CanvasStage",setup(e){const t=Ae(),i=o(null);let a=null;const r=n(()=>{const{scale:e,panX:n,panY:o}=t.viewport.state;return`translate(${n}px, ${o}px) scale(${e})`});function s(){const e=i.value;if(!e)return;const n=e.getBoundingClientRect();t.setMeasuredStageSize({w:n.width,h:n.height})}return c(()=>{d(s),"undefined"!=typeof ResizeObserver&&i.value&&(a=new ResizeObserver(s),a.observe(i.value)),window.addEventListener("resize",s)}),l(()=>{null==a||a.disconnect(),a=null,window.removeEventListener("resize",s)}),(e,n)=>(p(),f("div",{ref_key:"stageEl",ref:i,class:"hc-canvas-stage","data-hc-stage":""},[w("div",{class:"hc-canvas-stage__world","data-hc-stage-world":"",style:h({transform:r.value,transformOrigin:"0 0"})},[M(e.$slots,"default",{},void 0,!0)],4)],512))}})),xt=["data-mode"],bt=s({__name:"RuntimeLayer",props:{componentSourceMap:{},mode:{default:"design"},schedulerOptions:{},canvasId:{}},setup(e){const t=Ae(),o=n(()=>t.document.document);return(n,i)=>(p(),f("div",{class:"hc-runtime-layer","data-hc-runtime-layer":"","data-mode":e.mode,style:h({position:"absolute",top:0,left:0,pointerEvents:g(t).effectiveBehavior.value.selectable?"none":"auto"})},[T(vn,{document:o.value,"component-source-map":e.componentSourceMap,"scheduler-options":e.schedulerOptions,"canvas-id":e.canvasId},null,8,["document","component-source-map","scheduler-options","canvas-id"])],12,xt))}}),kt=8,St=.05;function Mt(e,n,t,o=0){if(!n||n.length<2)return[];if(e.w<=0||e.h<=0)return[];const i=n.map(e=>"number"==typeof e&&Number.isFinite(e)&&e>0?e:0),a=i.reduce((e,n)=>e+n,0);if(a<=0)return[];const r=i.length-1,s=Math.max(0,o)*r,c="horizontal"===t?e.w:e.h,d=Math.max(0,c-s);if(d<=0)return[];const l=o>0?o:8,u=[];let p=0;for(let n=0;n<r;n++){p+=i[n]/a*d;const r=p+n*o+o/2;let s;s="horizontal"===t?{x:e.x+r-l/2,y:e.y,w:l,h:e.h}:{x:e.x,y:e.y+r-l/2,w:e.w,h:l},u.push({index:n,rect:s,direction:t})}return u}function Tt(e,n,t,o,i=0){if(!e||n<0||n>=e.length-1)return e.slice();const a=e.map(e=>"number"==typeof e&&Number.isFinite(e)&&e>0?e:0),r=a[n],s=a[n+1],c=r+s;if(c<=0)return a;const d=a.length-1,l=Math.max(0,i)*d,u=Math.max(0,o-l);if(u<=0)return a;const p=a.reduce((e,n)=>e+n,0);if(p<=0)return a;const f=t/u*p,h=.05*p;let g=r+f,v=s-f;g<h&&(g=h,v=c-h),v<h&&(v=h,g=c-h);const y=a.slice();return y[n]=g,y[n+1]=v,y}function zt(t){const o=e({status:"idle",parentId:null,dividerIndex:null,startRatios:null,parentAxisPx:0,startPt:null,direction:null,gap:0}),i=n(()=>"active"===o.status);function a(){o.status="idle",o.parentId=null,o.dividerIndex=null,o.startRatios=null,o.parentAxisPx=0,o.startPt=null,o.direction=null,o.gap=0}return{drag:o,isDragging:i,handleSplitDividerStart:function(e){if(!e.parentId)return{startTracking:!1};if(e.dividerIndex<0)return{startTracking:!1};if(!e.startRatios||e.startRatios.length<2)return{startTracking:!1};const n=t.document.getInstance(e.parentId);return n&&n.containerLayout&&"split"===n.containerLayout.mode?(o.status="active",o.parentId=e.parentId,o.dividerIndex=e.dividerIndex,o.startRatios=e.startRatios.slice(),o.parentAxisPx=e.parentAxisPx,o.startPt={...e.canvasPt},o.direction=e.direction,o.gap=e.gap,t.beginBatch(),{startTracking:!0}):{startTracking:!1}},handleSplitDividerMove:function(e){if("active"!==o.status)return;if(!o.startPt||!o.startRatios||!o.direction||null===o.dividerIndex)return;const n=t.document.getInstance(o.parentId);if(!n||!n.containerLayout||"split"!==n.containerLayout.mode)return;const i="horizontal"===o.direction?e.x-o.startPt.x:e.y-o.startPt.y,a=Tt(o.startRatios,o.dividerIndex,i,o.parentAxisPx,o.gap),r=n.containerLayout;if(r.ratios.length===a.length&&r.ratios.every((e,n)=>e===a[n]))return;const s={...r,ratios:a};t.dispatch({type:"setContainerLayout",payload:{instanceId:o.parentId,containerLayout:s}})},handleSplitDividerEnd:function(){"active"===o.status&&(t.endBatch("split-divider-drag"),a())},cancelSplitDividerDrag:function(){"active"===o.status&&t.endBatch("split-divider-cancel"),a()}}}function Bt(e){return!0===(e.lockPosition??e.locked)}function Lt(e){return!0===(e.lockSize??e.locked)}function Pt(e){return Bt(e)||Lt(e)}const Ct=["data-mode"],$t=["data-selection-box","data-locked","data-placement"],Et=["data-lock-badge"],Ot=["data-resize-handle","data-resize-instance","onPointerdown"],Dt=["data-hc-divider-direction","data-hc-divider-index","data-hc-parent-id","data-hc-divider-dragging","onPointerdown"],Rt=["data-axis","data-kind"],At=["data-hc-reparent-state"],jt=["data-hc-reparent-ghost-reason"],Ft={key:0,"data-hc-reparent-ghost-reason-chip":"",style:{flex:"none",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:"10px",lineHeight:"14px",padding:"0 4px",borderRadius:"2px",background:"rgba(0, 0, 0, 0.25)",color:"#fff",whiteSpace:"nowrap"}},Nt=s({__name:"InteractionLayer",props:{mode:{default:"design"}},emits:["cannot-drag-slot-child","cannot-drag-layout-managed-child"],setup(e,{emit:i}){const a=i,s=Ae(),d=Hn(s,{getRoot:()=>H(),getDomBox:e=>{const n=_n(e,H(),s.viewport);return n?0===n.w&&0===n.h?null:n:null}}),I=zt(s),b=t(vt,null);r(()=>d.cannotDragSlotChildEvent.value,e=>{e&&a("cannot-drag-slot-child",{instanceId:e.instanceId,parentId:e.parentId})},{flush:"sync"}),r(()=>d.cannotDragLayoutManagedChildEvent.value,e=>{e&&a("cannot-drag-layout-managed-child",{instanceId:e.instanceId,parentId:e.parentId,parentLayoutMode:e.parentLayoutMode})},{flush:"sync"});const k=o(null);let S=null;const T=n(()=>{const e=new Set(s.selection.selectedIds.value);return s.document.document.instances.filter(n=>e.has(n.instanceId)&&!n.hidden)}),z=n(()=>s.measuredCanvasSize.value),B=u({});function L(){const e=H(),n={};for(const t of T.value)n[t.instanceId]=_n(t.instanceId,e,s.viewport);B.value=n}let P=null;function C(){"undefined"!=typeof requestAnimationFrame?null===P&&(P=requestAnimationFrame(()=>{P=null,L()})):L()}let $=null;function E(){$=null,L(),(d.isResizing.value||d.isDragging.value||I.isDragging.value)&&($=requestAnimationFrame(E))}function O(e){const n=B.value[e.instanceId];if(n)return n;const t=_n(e.instanceId,H(),s.viewport);if(t&&(t.w>0||t.h>0))return t;const o=e.layoutBox;return o?{x:o.x,y:o.y,w:o.width,h:o.height}:{x:e.rect.x,y:e.rect.y,w:e.rect.w,h:e.rect.h}}r(()=>s.selection.selectedIds.value,()=>{C()},{flush:"post",deep:!0}),r(()=>s.viewport.scale.value,()=>C()),r(()=>[s.viewport.panX.value,s.viewport.panY.value],()=>C()),r(()=>T.value.map(e=>{const n=e.layoutBox;return n?`${n.x}|${n.y}|${n.width}|${n.height}|${n.widthMode}|${n.heightMode}`:""}),()=>C(),{flush:"post",deep:!0}),r(()=>d.isResizing.value,e=>{e&&null===$&&($=requestAnimationFrame(E))}),r(()=>d.isDragging.value,e=>{e&&null===$&&($=requestAnimationFrame(E))}),r(()=>I.isDragging.value,e=>{e&&null===$&&($=requestAnimationFrame(E))}),c(()=>{C()});const D=n(()=>T.value.map(e=>({instance:e,box:O(e)}))),R=new Set(jn),A=n(()=>{if(!s.effectiveBehavior.value.resizable)return[];const e=[];for(const n of D.value){const t=n.instance;if(!0===(t.lockSize??t.locked))continue;if(!n.box)continue;const o=Kn(s,t.instanceId),{x:i,y:a,w:r,h:c}=n.box,d=[{handle:"nw",cx:i,cy:a,cursor:"nwse-resize"},{handle:"n",cx:i+r/2,cy:a,cursor:"ns-resize"},{handle:"ne",cx:i+r,cy:a,cursor:"nesw-resize"},{handle:"e",cx:i+r,cy:a+c/2,cursor:"ew-resize"},{handle:"se",cx:i+r,cy:a+c,cursor:"nwse-resize"},{handle:"s",cx:i+r/2,cy:a+c,cursor:"ns-resize"},{handle:"sw",cx:i,cy:a+c,cursor:"nesw-resize"},{handle:"w",cx:i,cy:a+c/2,cursor:"ew-resize"}];let l=d;"split"===o?l=[]:"flex"!==o&&"grid"!==o||(l=d.filter(e=>R.has(e.handle)));for(const n of l)e.push({instanceId:t.instanceId,handle:n.handle,left:n.cx-4,top:n.cy-4,cursor:n.cursor})}return e});function j(e,n,t){return"percent"===n?`${Math.round(t)}%`:"fill"===n?"fill":"auto"===n?"auto":String(Math.round(e))}const F=n(()=>{if(!d.isResizing.value)return null;const e=d.resize.instanceId;if(!e)return null;const n=s.document.getInstance(e);if(!n)return null;const t=O(n);if(!t)return null;const o=n.layoutBox,i=j(t.w,null==o?void 0:o.widthMode,(null==o?void 0:o.width)??t.w),a=j(t.h,null==o?void 0:o.heightMode,(null==o?void 0:o.height)??t.h);return{x:t.x,y:t.y,w:t.w,h:t.h,wText:i,hText:a}}),N={nw:"nwse-resize",se:"nwse-resize",ne:"nesw-resize",sw:"nesw-resize",n:"ns-resize",s:"ns-resize",w:"ew-resize",e:"ew-resize"},q=n(()=>{var e,n;const t=new Set;for(const o of T.value)if("split"===(null==(e=o.containerLayout)?void 0:e.mode)&&t.add(o.instanceId),o.parentId){const e=s.document.getInstance(o.parentId);"split"===(null==(n=null==e?void 0:e.containerLayout)?void 0:n.mode)&&t.add(e.instanceId)}if(0===t.size)return[];const o=[];for(const e of t){const n=s.document.getInstance(e);if(!n)continue;const t=n.containerLayout;if(!t||"split"!==t.mode)continue;const i=O(n);if(!i)continue;const a=t,r=a.direction,c=a.gap??0,d=a.ratios??[],l=Mt(i,d,r,c);0!==l.length&&o.push({parentId:e,direction:r,gap:c,ratios:d.slice(),parentBox:i,dividers:l})}return o}),V=n(()=>d.isResizing.value&&d.resize.handle?N[d.resize.handle]:I.isDragging.value?"horizontal"===I.drag.direction?"ew-resize":"ns-resize":d.isDragging.value?"grabbing":"hand"===s.toolMode.value?Q?"grabbing":"grab":"marquee"===s.toolMode.value?"crosshair":"default"),K=u(null);function J(){if(!b)return!1;if(!d.isDragging.value)return!1;if(1!==d.drag.startRects.size)return!1;const e=Array.from(d.drag.startRects.keys())[0],n=s.document.getInstance(e);return!!n&&((void 0===n.placement||"canvas"===n.placement||"absolute"===n.placement)&&!0!==(n.lockPosition??n.locked)&&!n.hidden)}let _=null,X=null;function Y(e){if(!J()||!b)return void(null!==K.value&&(K.value=null));const n=Array.from(d.drag.startRects.keys())[0],t=b.getDropTarget(e,{excludeInstanceId:n});if(!t)return void(null!==K.value&&(K.value=null));const o=s.document.getInstance(n);if(o&&o.parentId===t.parentId&&(o.slot??"default")===(t.slot||"default"))return void(null!==K.value&&(K.value=null));const i=function(e){const n=H();if(!n)return null;const t=e.getBoundingClientRect(),o=n.getBoundingClientRect(),i=s.viewport.toCanvasPoint({x:t.left-o.left,y:t.top-o.top}),a=s.viewport.toCanvasPoint({x:t.right-o.left,y:t.bottom-o.top});return{x:i.x,y:i.y,w:Math.max(0,a.x-i.x),h:Math.max(0,a.y-i.y)}}(t.outletEl);if(!i)return void(null!==K.value&&(K.value=null));const a={parentId:t.parentId,slot:t.slot},r=b.canReparent(n,a);K.value={rect:i,target:t,result:r}}const U=n(()=>K.value);function H(){return S||(k.value?(S=k.value.closest("[data-hc-stage]"),S):null)}function G(e){const n=H();if(!n)return;const t=On({x:e.clientX,y:e.clientY},n,s.viewport);s.setMouseCanvasPoint(t)}function W(){s.setMouseCanvasPoint(null)}let Q=null;function Z(e){if(0!==e.button)return;const n=H();if(!n)return;if("hand"===s.toolMode.value)return Q={clientX:e.clientX,clientY:e.clientY,panX:s.viewport.panX.value,panY:s.viewport.panY.value},window.addEventListener("pointermove",ee),window.addEventListener("pointerup",ne),void e.preventDefault();const t=On({x:e.clientX,y:e.clientY},n,s.viewport),{startTracking:o}=d.handlePointerDown(t,{shift:e.shiftKey,ctrl:e.ctrlKey,meta:e.metaKey});o&&(te(),e.preventDefault())}function ee(e){if(!Q)return;const n=e.clientX-Q.clientX,t=e.clientY-Q.clientY;s.viewport.setPan(Q.panX+n,Q.panY+t)}function ne(){Q=null,window.removeEventListener("pointermove",ee),window.removeEventListener("pointerup",ne)}function te(){window.addEventListener("pointermove",oe),window.addEventListener("pointerup",ie),window.addEventListener("keydown",ae)}function oe(e){const n=H();if(!n)return;const t=On({x:e.clientX,y:e.clientY},n,s.viewport);var o;d.handlePointerMove(t),I.handleSplitDividerMove(t),I.isDragging.value&&C(),o={x:e.clientX,y:e.clientY},_=o,"undefined"!=typeof requestAnimationFrame?null===X&&(X=requestAnimationFrame(()=>{X=null,_&&Y(_)})):Y(o)}function ie(e){if(I.isDragging.value)return I.handleSplitDividerEnd(),void re();e&&b&&J()&&Y({x:e.clientX,y:e.clientY}),null!==X&&"undefined"!=typeof cancelAnimationFrame&&(cancelAnimationFrame(X),X=null);const n=K.value;if(n&&b){const e=Array.from(d.drag.startRects.keys())[0];return n.result.ok&&e?(d.cancelDrag(),b.moveInstanceInTree(e,{parentId:n.target.parentId,slot:n.target.slot})):d.cancelDrag(),K.value=null,void re()}d.handlePointerUp(),re()}function ae(e){"Escape"===e.key&&(d.cancelResize(),d.cancelDrag(),d.cancelMarquee(),I.cancelSplitDividerDrag(),K.value=null,null!==X&&"undefined"!=typeof cancelAnimationFrame&&(cancelAnimationFrame(X),X=null),ne(),re())}function re(){window.removeEventListener("pointermove",oe),window.removeEventListener("pointerup",ie),window.removeEventListener("keydown",ae)}return l(()=>{d.cancelResize(),d.cancelDrag(),d.cancelMarquee(),I.cancelSplitDividerDrag(),K.value=null,re(),ne(),null!==P&&"undefined"!=typeof cancelAnimationFrame&&(cancelAnimationFrame(P),P=null),null!==$&&"undefined"!=typeof cancelAnimationFrame&&(cancelAnimationFrame($),$=null),null!==X&&"undefined"!=typeof cancelAnimationFrame&&(cancelAnimationFrame(X),X=null),_=null}),(n,t)=>(p(),f("div",{ref_key:"layerEl",ref:k,class:"hc-interaction-layer","data-hc-interaction-layer":"","data-mode":e.mode,style:h({position:"absolute",top:0,left:0,width:z.value.w+"px",height:z.value.h+"px",pointerEvents:g(s).effectiveBehavior.value.selectable?"auto":"none",cursor:V.value,zIndex:9999}),onPointerdown:Z,onPointermove:G,onPointerleave:W},[(p(!0),f(y,null,m(D.value,e=>(p(),f(y,{key:"sel-"+e.instance.instanceId},[e.box?(p(),f("div",{key:0,class:"hc-selection-box","data-selection-box":e.instance.instanceId,"data-locked":g(Pt)(e.instance)?"true":"false","data-placement":e.instance.placement??"absolute",style:h({position:"absolute",left:e.box.x+"px",top:e.box.y+"px",width:e.box.w+"px",height:e.box.h+"px",border:"2px solid "+(g(Pt)(e.instance)?"#9ca3af":"#3b82f6"),boxSizing:"border-box",pointerEvents:"none",boxShadow:"0 0 0 1px rgba(59, 130, 246, 0.2)"})},null,12,$t)):v("",!0)],64))),128)),(p(!0),f(y,null,m(D.value.filter(e=>g(Pt)(e.instance)),e=>(p(),f(y,{key:"lock-"+e.instance.instanceId},[e.box?(p(),f("div",{key:0,class:"hc-lock-badge","data-lock-badge":e.instance.instanceId,style:h({position:"absolute",left:e.box.x+e.box.w-18+"px",top:e.box.y+2+"px",width:"16px",height:"16px",background:"#9ca3af",color:"#fff",fontSize:"11px",lineHeight:"16px",textAlign:"center",borderRadius:"3px",pointerEvents:"none",userSelect:"none"})},"🔒",12,Et)):v("",!0)],64))),128)),(p(!0),f(y,null,m(A.value,e=>(p(),f("div",{key:"rh-"+e.instanceId+"-"+e.handle,class:"hc-resize-handle","data-resize-handle":e.handle,"data-resize-instance":e.instanceId,style:h({position:"absolute",left:e.left+"px",top:e.top+"px",width:"8px",height:"8px",background:"#fff",border:"1px solid #3b82f6",boxSizing:"border-box",cursor:e.cursor,pointerEvents:"auto",zIndex:2}),onPointerdown:n=>function(e,n,t){if(0!==e.button)return;e.stopPropagation();const o=H();if(!o)return;const i=On({x:e.clientX,y:e.clientY},o,s.viewport),{startTracking:a}=d.handleResizeStart(n,t,i);a&&(te(),e.preventDefault())}(n,e.instanceId,e.handle)},null,44,Ot))),128)),(p(!0),f(y,null,m(q.value,e=>(p(),f(y,{key:"sd-parent-"+e.parentId},[(p(!0),f(y,null,m(e.dividers,t=>(p(),f(y,{key:"sd-"+e.parentId+"-"+t.index},[n.$slots["split-divider"]?M(n.$slots,"split-divider",{key:0,state:{parentId:e.parentId,dividerIndex:t.index,direction:t.direction,rect:t.rect,isDragging:g(I).isDragging.value&&g(I).drag.parentId===e.parentId&&g(I).drag.dividerIndex===t.index}}):(p(),f("div",{key:1,class:"hc-split-divider","data-hc-divider-direction":t.direction,"data-hc-divider-index":t.index,"data-hc-parent-id":e.parentId,"data-hc-divider-dragging":g(I).isDragging.value&&g(I).drag.parentId===e.parentId&&g(I).drag.dividerIndex===t.index?"true":"false",style:h({position:"absolute",left:t.rect.x+"px",top:t.rect.y+"px",width:t.rect.w+"px",height:t.rect.h+"px",background:g(I).isDragging.value&&g(I).drag.parentId===e.parentId&&g(I).drag.dividerIndex===t.index?"rgba(59, 130, 246, 0.6)":"rgba(59, 130, 246, 0.18)",cursor:"horizontal"===t.direction?"ew-resize":"ns-resize",pointerEvents:"auto",boxSizing:"border-box",zIndex:3}),onPointerdown:n=>function(e,n,t){if(0!==e.button)return;e.stopPropagation();const o=H();if(!o)return;const i=s.document.getInstance(n);if(!i)return;const a=i.containerLayout;if(!a||"split"!==a.mode)return;const r=a,c=O(i);if(!c)return;const d="horizontal"===r.direction?c.w:c.h,l=On({x:e.clientX,y:e.clientY},o,s.viewport),{startTracking:u}=I.handleSplitDividerStart({parentId:n,dividerIndex:t,startRatios:(r.ratios??[]).slice(),parentAxisPx:d,direction:r.direction,gap:r.gap??0,canvasPt:l});u&&(te(),e.preventDefault())}(n,e.parentId,t.index)},null,44,Dt))],64))),128))],64))),128)),F.value?(p(),f("div",{key:0,class:"hc-resize-badge","data-resize-badge":"",style:h({position:"absolute",left:F.value.x+"px",top:F.value.y-22+"px",padding:"2px 6px",background:"#3b82f6",color:"#fff",fontSize:"11px",lineHeight:"14px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",whiteSpace:"nowrap",fontFamily:"ui-monospace, SFMono-Regular, monospace"})},x(F.value.wText)+" × "+x(F.value.hText),5)):v("",!0),g(d).marqueeRect.value?(p(),f("div",{key:1,class:"hc-marquee-box","data-marquee-box":"",style:h({position:"absolute",left:g(d).marqueeRect.value.x+"px",top:g(d).marqueeRect.value.y+"px",width:g(d).marqueeRect.value.w+"px",height:g(d).marqueeRect.value.h+"px",border:"1px dashed #3b82f6",background:"rgba(59, 130, 246, 0.08)",pointerEvents:"none",boxSizing:"border-box"})},null,4)):v("",!0),(p(!0),f(y,null,m(g(d).snapLines.value,(e,n)=>(p(),f("div",{key:"snap-"+n,class:"hc-snap-line","data-snap-line":"","data-axis":e.axis,"data-kind":e.kind,style:h("x"===e.axis?{position:"absolute",left:e.pos+"px",top:e.from+"px",width:"0px",height:e.to-e.from+"px",borderLeft:"1px dashed #ec4899",pointerEvents:"none"}:{position:"absolute",left:e.from+"px",top:e.pos+"px",width:e.to-e.from+"px",height:"0px",borderTop:"1px dashed #ec4899",pointerEvents:"none"})},null,12,Rt))),128)),U.value?(p(),f(y,{key:2},[n.$slots["reparent-ghost"]?M(n.$slots,"reparent-ghost",{key:0,state:U.value}):(p(),f("div",{key:1,class:"hc-reparent-ghost","data-hc-reparent-ghost":"","data-hc-reparent-state":U.value.result.ok?"legal":"illegal",style:h({position:"absolute",left:U.value.rect.x+"px",top:U.value.rect.y+"px",width:U.value.rect.w+"px",height:U.value.rect.h+"px",pointerEvents:"none",boxSizing:"border-box",border:"2px solid "+(U.value.result.ok?"#22c55e":"#ef4444"),background:U.value.result.ok?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)"})},[!U.value.result.ok&&U.value.result.message?(p(),f("div",{key:0,class:"hc-reparent-ghost__message","data-hc-reparent-ghost-message":"","data-hc-reparent-ghost-reason":U.value.result.reason||"",style:{position:"absolute",left:"0",top:"100%",marginTop:"4px",maxWidth:"280px",padding:"3px 6px",background:"#ef4444",color:"#fff",fontSize:"11px",lineHeight:"16px",borderRadius:"3px",whiteSpace:"normal",wordBreak:"break-all",pointerEvents:"none",display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"4px"}},[U.value.result.reason?(p(),f("span",Ft,"["+x(U.value.result.reason)+"]",1)):v("",!0),w("span",null,x(U.value.result.message),1)],8,jt)):v("",!0)],12,At))],64)):v("",!0)],44,Ct))}}),qt=s({__name:"HyperCardCanvasDesigner",props:{modelValue:{},componentSourceMap:{},mode:{default:"design"},schedulerOptions:{},adapters:{},canvasId:{}},emits:["update:modelValue","context-ready","handle-ready","cannot-drag-slot-child","cannot-drag-layout-managed-child"],setup(e,{expose:n,emit:t}){const i=e,s=t;let u=!1;const h=De({initialDocument:i.modelValue,getMode:()=>i.mode,adapters:i.adapters});Re(h);const y=o(null),m=gt(h,{getStageEl:()=>{var e;return(null==(e=y.value)?void 0:e.querySelector("[data-hc-stage]"))??null},resolveContract:function(e){var n;const t=null==(n=i.componentSourceMap)?void 0:n[e];if(t)return"contract"in t&&t.contract?t.contract:void 0}}),I=i.canvasId??function(){const e=globalThis.crypto;return e&&"function"==typeof e.randomUUID?`hc-designer-${e.randomUUID()}`:`hc-designer-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}(),w=!!h.adapters.data,x=tn({canvasId:I,source:{getDocument:()=>h.document.document,onAction:e=>h.registerHooks({onAfterAction:n=>e(n)})},initialMode:It(i.mode),dataStore:w?h.dataStore:void 0});m.attachBindingDelegate(x,w?h.dataStore:null),s("context-ready",h),s("handle-ready",m);const k={getDropTarget:(e,n)=>m.getDropTarget(e,y.value,n),canReparent:(e,n)=>m.canReparent(e,n),moveInstanceInTree:(e,n)=>m.moveInstanceInTree(e,n),cannotReparentEvent:m.cannotReparentEvent};function S(){s("update:modelValue",JSON.parse(JSON.stringify(h.document.document)))}return a(vt,k),r(()=>i.modelValue,(e,n)=>{if(e&&e!==n){u=!0;try{h.suppressRecording(()=>{h.dispatch({type:"replaceDocument",payload:{document:e}})})}finally{u=!1}}}),r(()=>h.document.document,()=>{u||h.isBatching.value||S()},{deep:!0,flush:"sync"}),r(()=>h.isBatching.value,(e,n)=>{!n||e||u||S()},{flush:"sync"}),c(()=>{wn(I,m),d(()=>{x.setMode(It(i.mode))})}),r(()=>i.mode,e=>{x.setMode(It(e))}),l(()=>{x.dispose(),m.attachBindingDelegate(null,null),xn(I),m.dispose(),h.dispose()}),n({context:h,handle:m,canvasId:I}),(n,t)=>(p(),f("div",{ref_key:"stageContainerEl",ref:y,class:"hc-canvas-designer",style:{width:"100%",height:"100%",position:"relative"},"data-hc-canvas-designer":""},[T(wt,null,{default:z(()=>[T(bt,{"component-source-map":e.componentSourceMap,mode:e.mode,"scheduler-options":e.schedulerOptions,"canvas-id":g(I)},null,8,["component-source-map","mode","scheduler-options","canvas-id"]),"runtime"!==e.mode?(p(),b(Nt,{key:0,mode:e.mode,onCannotDragSlotChild:t[0]||(t[0]=e=>s("cannot-drag-slot-child",e)),onCannotDragLayoutManagedChild:t[1]||(t[1]=e=>s("cannot-drag-layout-managed-child",e))},B({_:2},[n.$slots["reparent-ghost"]?{name:"reparent-ghost",fn:z(e=>[M(n.$slots,"reparent-ghost",L(P(e)))]),key:"0"}:void 0,n.$slots["split-divider"]?{name:"split-divider",fn:z(e=>[M(n.$slots,"split-divider",L(P(e)))]),key:"1"}:void 0]),1032,["mode"])):v("",!0),M(n.$slots,"canvas-overlay",{viewport:g(m).viewport,handle:g(m)}),M(n.$slots,"default")]),_:3})],512))}});function Vt(e={}){const{canvasWidth:n=1280,canvasHeight:t=720,rootLayout:o="free",instances:i=[],bindings:a=[]}=e;return{schemaVersion:"1",layout:{type:"free",canvas:{width:{mode:"px",value:n},height:{mode:"px",value:t}},rootLayout:"string"==typeof o?{mode:o}:o},instances:i,bindings:a}}function Kt(e={}){return Vt({...e,rootLayout:"free"})}const Jt={event:["instanceEvent"],init:["lifecycle","page"],data:["dataSource"]};function _t(e){return Jt[e.type].includes(e.source.kind)}function Xt(e,n){var t,o,i;const a=[],r=new Map;for(const n of e.instances)r.set(n.instanceId,n);const s=null==n?void 0:n.currentCanvasId,c=null==n?void 0:n.resolveContract;let d=null,l=null;if(c){d=new Map,l=new Map;for(const n of e.instances){const e=c(n.componentVersionKey);if(d.set(n.instanceId,e),e)for(const t of e.dataInputsDecl)if(t.required){let e=l.get(n.instanceId);e||(e=new Set,l.set(n.instanceId,e)),e.add(t.key)}}}for(const n of e.bindings)if(_t(n)){if(void 0!==s){const e=Ht(n),t=Gt(n);void 0!==e&&e!==s&&a.push(Yt("unsupported-cross-canvas","error",n,{canvasId:e})),void 0!==t&&t!==s&&a.push(Yt("unsupported-cross-canvas","error",n,{canvasId:t}))}switch(n.source.kind){case"instanceEvent":{const e=n.source.event,t=r.get(n.source.instanceId);if(t){if(d){const o=d.get(t.instanceId);o&&!o.emitsDecl.some(n=>n.event===e)&&a.push(Yt("unknown-source-event","error",n,{instanceId:t.instanceId}))}}else a.push(Yt("orphan-binding","warn",n,{instanceId:n.source.instanceId}));break}case"lifecycle":r.get(n.source.instanceId)||a.push(Yt("orphan-binding","warn",n,{instanceId:n.source.instanceId}))}switch(n.target.kind){case"instanceMethod":{const e=n.target.method,t=r.get(n.target.instanceId);if(t){if(d){const o=d.get(t.instanceId);o&&!o.methodsDecl.some(n=>n.key===e)&&a.push(Yt("unknown-target-method","error",n,{instanceId:t.instanceId}))}}else a.push(Yt("orphan-binding","warn",n,{instanceId:n.target.instanceId}));break}case"instanceEmit":{const e=n.target.event,t=r.get(n.target.instanceId);if(t){if(d){const o=d.get(t.instanceId);o&&!o.emitsDecl.some(n=>n.event===e)&&a.push(Yt("unknown-target-event","error",n,{instanceId:t.instanceId}))}}else a.push(Yt("orphan-binding","warn",n,{instanceId:n.target.instanceId}));break}case"instanceDataInput":{const e=n.target.key,o=r.get(n.target.instanceId);if(o){if(d){const i=d.get(o.instanceId);i&&!i.dataInputsDecl.some(n=>n.key===e)?a.push(Yt("unknown-target-data-input","error",n,{instanceId:o.instanceId})):l&&(null==(t=l.get(o.instanceId))||t.delete(e))}}else a.push(Yt("orphan-binding","warn",n,{instanceId:n.target.instanceId}));break}}(null==(o=n.schedule)?void 0:o.throttle)&&n.schedule.throttle.windowMs<16&&a.push(Yt("schedule-window-too-small","info",n,Ut(n))),(null==(i=n.schedule)?void 0:i.debounce)&&n.schedule.debounce.windowMs<16&&a.push(Yt("schedule-window-too-small","info",n,Ut(n)))}else a.push(Yt("invalid-type-source-kind","error",n,Ut(n)));if(l)for(const[e,n]of l)for(const t of n){const n={level:"warn",code:"required-data-input-missing",instanceId:e,key:t,message:`Required dataInput "${t}" on instance "${e}" is not fed by any binding`};a.push(n)}return a}function Yt(e,n,t,o){const i={level:n,code:e,bindingId:t.id,message:`${e} on binding "${t.id}"`};return o.instanceId&&(i.instanceId=o.instanceId),o.canvasId&&(i.canvasId=o.canvasId),i}function Ut(e){return"instanceEvent"===e.source.kind||"lifecycle"===e.source.kind?{instanceId:e.source.instanceId}:"instanceMethod"===e.target.kind||"instanceDataInput"===e.target.kind||"instanceEmit"===e.target.kind?{instanceId:e.target.instanceId}:{}}function Ht(e){switch(e.source.kind){case"instanceEvent":case"lifecycle":return e.source.canvasId;case"page":case"dataSource":return}}function Gt(e){switch(e.target.kind){case"instanceMethod":case"instanceEmit":case"instanceDataInput":return e.target.canvasId}}const Wt="0.0.0-d3.6c-stage";export{Oe as CANVAS_CONTEXT_KEY,vt as CANVAS_REPARENT_BRIDGE_KEY,wt as CanvasStage,it as DEFAULT_FIT_PADDING,kt as DIVIDER_HIT_THICKNESS,Cn as DRAG_THRESHOLD_CANVAS_PX,je as EFFECTIVE_DEFAULT_SLOT,qt as HyperCardCanvasDesigner,vn as HyperCardPageRenderer,Nt as InteractionLayer,Fe as MAX_INSTANCE_TREE_DEPTH,$n as MIN_INSTANCE_SIZE,St as MIN_RATIO_FRACTION,bt as RuntimeLayer,jn as SLOT_CHILD_RESIZE_HANDLES,Wt as VERSION,J as applyEffectiveSplitRatiosToDocument,Tt as applySplitDividerDrag,ke as assertNeverBindingSource,Se as assertNeverBindingTarget,It as bindingModeForCanvasMode,be as bindingReferencesInstance,Qn as buildInstanceTree,Wn as canReparent,se as canvasSizeToCss,Ie as cleanLayoutItem,On as clientToCanvas,rt as computeContentBounds,Q as computeEffectiveSplitRatios,ct as computeFit,Mn as computeInverse,Xn as computeNextAxisSize,Yn as computeNextLayoutBoxAxis,ye as computeParentLayoutMode,st as computeSelectionBounds,_n as computeSlotChildCanvasRect,Pn as computeSnap,Mt as computeSplitDividers,dt as computeVisibleBounds,ae as containerLayoutToCss,Ce as createAssetResolver,De as createCanvasContext,gt as createCanvasHandle,Hn as createCanvasInteraction,Bn as createCommandRecorder,Be as createDocumentStore,Kt as createFreePageDocument,Vt as createMinimalPageDocument,we as createRenderScheduler,Le as createSelectionStore,zt as createSplitDividerInteraction,Pe as createViewportStore,Ne as effectiveSlot,ze as emptyPageDocument,Un as filterExistingIds,An as filterInstancesInRect,tt as findInstanceBreadcrumb,nt as findInstancePath,xe as getBindingInstanceRefs,ht as getDefaultShortcuts,bn as getDesignerHandle,Vn as getInstanceWrapperRectFromDom,Nn as getOutletRectFromDom,Kn as getParentLayoutMode,ot as getSiblings,qn as getSlotChildRectFromDom,Dn as hitTestInstance,En as isAdditive,me as isCanvasRootPlacement,ve as isContainerChildPlacement,yt as isDraftKey,ut as isEditingText,Jn as isFreePositionLayoutMode,Pt as isInstanceEffectivelyLocked,Bt as isInstancePositionLocked,Lt as isInstanceSizeLocked,ee as isV1Layout,re as layoutItemToCss,kn as listRegisteredCanvasIds,pt as matchBinding,he as migrateInstanceToLayoutBox,Z as migrateLayoutV0ToV1,fe as migratePlacementToCanvasContainer,ge as migrateRootLayout,_ as normalizeComponentOverrides,X as normalizeInstanceSlotFields,ft as normalizeKeyString,Rn as normalizeMarqueeRect,N as normalizePageBindings,K as normalizePageDocument,mt as parseComponentVersionKey,lt as parseKeyEvent,Re as provideCanvasContext,wn as registerDesignerHandle,oe as renderLayoutBoxStyle,ne as resolveCanvasSizePx,te as resolveMeasuredCanvasSizePx,Sn as subscribeDesignerRegistry,at as unionRects,xn as unregisterDesignerHandle,Ae as useCanvasContext,Xt as validateBindings,qe as validateInstanceTree,tn as wirePageBindings};
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hy-bricks/canvas",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "HyperCard 画布 — 多组件实例编排 / 自由布局 / 拖拽 / 连线 / 属性面板。受控组件,SDK 边界守住:不 fetch / 不知后端 / 不开 Drawer。",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"hypercard",
|
|
7
|
+
"low-code",
|
|
8
|
+
"vue3",
|
|
9
|
+
"canvas",
|
|
10
|
+
"drag-drop",
|
|
11
|
+
"layout-engine",
|
|
12
|
+
"binding"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.cjs",
|
|
16
|
+
"module": "./dist/index.mjs",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.mjs",
|
|
22
|
+
"require": "./dist/index.cjs"
|
|
23
|
+
},
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"vue": "^3.5.0",
|
|
36
|
+
"@hy-bricks/core": "^0.1.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
40
|
+
"@vue/test-utils": "^2.4.10",
|
|
41
|
+
"jsdom": "^29.1.1",
|
|
42
|
+
"rimraf": "^5.0.10",
|
|
43
|
+
"terser": "^5.47.1",
|
|
44
|
+
"typescript": "~5.6.3",
|
|
45
|
+
"vite": "^6.0.3",
|
|
46
|
+
"vite-plugin-css-injected-by-js": "^5.0.1",
|
|
47
|
+
"vite-plugin-dts": "^4.4.0",
|
|
48
|
+
"vitest": "^2.1.9",
|
|
49
|
+
"vue": "^3.5.13",
|
|
50
|
+
"vue-tsc": "^2.1.10"
|
|
51
|
+
},
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"author": "hy_top",
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "vite build",
|
|
56
|
+
"dev": "vite build --watch",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"test:watch": "vitest",
|
|
59
|
+
"type-check": "vue-tsc --noEmit",
|
|
60
|
+
"clean": "rimraf dist .turbo"
|
|
61
|
+
}
|
|
62
|
+
}
|