frameboard 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -61,19 +61,19 @@ Error generating stack: `+e.message+`
61
61
  `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Ev,c=!wy.jitless,l=c&&Dv.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Wx([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function qx(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!qv(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>$v(e,r,Ty())))}),t)}var Jx=$(`$ZodUnion`,(e,t)=>{Gb.init(e,t),my(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),my(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),my(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),my(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>mv(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>qx(t,r,e,i)):qx(o,r,e,i)}}),Yx=$(`$ZodIntersection`,(e,t)=>{Gb.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Zx(e,t,n)):Zx(e,i,a)}});function Xx(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ov(e)&&Ov(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Xx(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Xx(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Zx(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Xx(t.value,n.value);if(!c.valid){if(qv(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Qx=$(`$ZodEnum`,(e,t)=>{Gb.init(e,t);let n=cv(t.entries),r=new Set(n);e._zod.values=r,my(e,`pattern`,e=>{let t=cv(e.def.entries).filter(e=>Av.has(typeof e));return RegExp(t.length?`^(${t.map(e=>jv(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),$x=$(`$ZodLiteral`,(e,t)=>{Gb.init(e,t);let n=new Set(t.values);e._zod.values=n,my(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?jv(e):e?jv(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),eS=$(`$ZodTransform`,(e,t)=>{Gb.init(e,t),e._zod.optin=`optional`,wy.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Cy(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Sy;return n.value=i,n}});function tS(e,t){return e.value=t.issues.length?void 0:t.value,e}var nS=$(`$ZodOptional`,(e,t)=>{Gb.init(e,t),my(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,my(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),my(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${mv(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>tS(e,t)):tS(e,r)}return t.innerType._zod.run(e,n)}}),rS=$(`$ZodExactOptional`,(e,t)=>{nS.init(e,t),my(e,`values`,e=>e.def.innerType._zod.values),my(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),iS=$(`$ZodNullable`,(e,t)=>{Gb.init(e,t),my(e,`optin`,e=>e.def.innerType._zod.optin),my(e,`optout`,e=>e.def.innerType._zod.optout),my(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${mv(t.source)}|null)$`):void 0}),my(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),aS=$(`$ZodDefault`,(e,t)=>{Gb.init(e,t),e._zod.optin=`defaulted`,my(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>oS(e,t)):oS(r,t)}});function oS(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var sS=$(`$ZodPrefault`,(e,t)=>{Gb.init(e,t),e._zod.optin=`defaulted`,my(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),cS=$(`$ZodNonOptional`,(e,t)=>{Gb.init(e,t),my(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>lS(t,e)):lS(i,e)}});function lS(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function uS(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>$v(e,r,Ty()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var dS=$(`$ZodCatch`,(e,t)=>{Gb.init(e,t),my(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),my(e,`optout`,e=>e.def.innerType._zod.optout),my(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>uS(e,r,t,n)):uS(e,r,t,n)}}),fS=$(`$ZodPipe`,(e,t)=>{Gb.init(e,t),my(e,`values`,e=>e.def.in._zod.values),my(e,`optin`,e=>e.def.in._zod.optin),my(e,`optout`,e=>e.def.out._zod.optout),my(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>pS(e,t.in,n)):pS(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>pS(e,t.out,n)):pS(r,t.out,n)}});function pS(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var mS=$(`$ZodReadonly`,(e,t)=>{Gb.init(e,t),my(e,`propValues`,e=>e.def.innerType._zod.propValues),my(e,`values`,e=>e.def.innerType._zod.values),my(e,`optin`,e=>e.def.innerType?._zod?.optin),my(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(hS):hS(r)}});function hS(e){return e.memo||(e.value=Object.freeze(e.value)),e}var gS=$(`$ZodCustom`,(e,t)=>{Ab.init(e,t),Gb.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>_S(t,n,r,e));_S(i,n,r,e)}});function _S(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(iy(e))}}var vS=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},yS=`~memo`,bS=[];function xS(e){return typeof e==`object`&&!!e}function SS(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var CS=new WeakMap,wS=0,TS=1,ES=2;function DS(e,t,n){let r=CS.get(e);if(r!==void 0)return r?ES:wS;if(t.has(e))return ES;t.add(e);let i=wS,a=e=>{if(i!==ES&&e?._zod){let r=DS(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=wS;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?TS:o.value?._zod?DS(o.value,t,n):wS;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=gv(c);s(e?o(e,!0):TS),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?DS(r,t,!1):TS);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),OS(e,i)}function OS(e,t){return t!==TS&&CS.set(e,t===ES),t}function kS(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var AS,jS=[],MS={alloc(e,t,n){let r=AS;if(!r)return n;AS=void 0;let i={value:n,issues:null};return r.set(t.value,i),jS.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&PS(n,e.value))throw new vS;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=DS(e,new Set,!1);if(i===wS)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===ES||r?n=!0:r=!0}let l=s.value;if(!xS(l))return t(s,c);let u=c[yS];u||(u={buckets:new WeakMap,backEdges:void 0},c[yS]=u);let d;i===c?d=a:(d=kS(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...SS(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;AS=d;let p=jS.length,m=t(s,c);AS=void 0;let h=jS.length>p?jS.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?SS(e.issues):bS),e)):(h&&(h.issues=m.issues.length?SS(m.issues):bS),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function NS(){return MS}function PS(e,t){let n=e[yS]?.backEdges;return n!==void 0&&xS(t)&&n.has(t)}var FS=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(ry(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Pv(e.values[0])}`:`Invalid option: expected one of ${lv(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${lv(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function IS(){return{localeError:FS()}}var LS,RS=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function zS(){return new RS}(LS=globalThis).__zod_globalRegistry??(LS.__zod_globalRegistry=zS());var BS=globalThis.__zod_globalRegistry;function VS(e){return e.checks&&=[...e.checks],e}function HS(e,t){return new e(VS({type:`string`,...Nv(t)}))}function US(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Nv(t)})}function WS(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Nv(t)})}function GS(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Nv(t)})}function KS(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Nv(t)})}function qS(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Nv(t)})}function JS(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Nv(t)})}function YS(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Nv(t)})}function XS(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Nv(t)})}function ZS(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Nv(t)})}function QS(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Nv(t)})}function $S(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Nv(t)})}function eC(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Nv(t)})}function tC(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Nv(t)})}function nC(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Nv(t)})}function rC(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Nv(t)})}function iC(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Nv(t)})}function aC(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Nv(t)})}function oC(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Nv(t)})}function sC(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Nv(t)})}function cC(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Nv(t)})}function lC(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Nv(t)})}function uC(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Nv(t)})}function dC(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Nv(t)})}function fC(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Nv(t)})}function pC(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Nv(t)})}function mC(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Nv(t)})}function hC(e){return new e({type:`unknown`})}function gC(e,t){return new e({type:`never`,...Nv(t)})}function _C(e,t){return new Mb({check:`max_length`,...Nv(t),maximum:e})}function vC(e,t){return new Nb({check:`min_length`,...Nv(t),minimum:e})}function yC(e,t){return new Pb({check:`length_equals`,...Nv(t),length:e})}function bC(e,t){return new Ib({check:`string_format`,format:`regex`,...Nv(t),pattern:e})}function xC(e){return new Lb({check:`string_format`,format:`lowercase`,...Nv(e)})}function SC(e){return new Rb({check:`string_format`,format:`uppercase`,...Nv(e)})}function CC(e,t){return new zb({check:`string_format`,format:`includes`,...Nv(t),includes:e})}function wC(e,t){return new Bb({check:`string_format`,format:`starts_with`,...Nv(t),prefix:e})}function TC(e,t){return new Vb({check:`string_format`,format:`ends_with`,...Nv(t),suffix:e})}function EC(e){return new Hb({check:`overwrite`,tx:e})}function DC(e){return EC(t=>t.normalize(e))}function OC(){return EC(e=>e.trim())}function kC(){return EC(e=>e.toLowerCase())}function AC(){return EC(e=>e.toUpperCase())}function jC(){return EC(e=>wv(e))}function MC(e,t,n){return new e({type:`array`,element:t,...Nv(n)})}function NC(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Nv(n)})}function PC(e,t){let n=FC(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(iy(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(iy(r))}},e(t.value,t)),t);return n}function FC(e,t){let n=new Ab({check:`custom`,...Nv(t)});return n._zod.check=e,n}function IC(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&hv(e,t,n[t]);return e}function LC(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??BS,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function RC(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function zC(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,zC(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&IC(o.schema,c),t.io===`input`&&YC(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function BC(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function VC(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${BC(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+BC(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
62
62
 
63
63
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function HC(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;HC(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var UC=new Set([`type`,`properties`,`required`,`additionalProperties`]),WC=[`oneOf`,`anyOf`];function GC(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function KC(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!UC.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??GC(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}hv(n,r,e.length===1?e[0]:KC(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=GC(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function qC(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of UC)if(t in e)return;let n=t.filter(e=>WC.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=KC(t);else{let e=n[0],i=WC.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>KC([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,IC(e,r))}function JC(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):IC(i,s),IC(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())HC(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])qC(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}IC(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,hv(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:ZC(t,`input`,e.processors),output:ZC(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function YC(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return YC(r.element,n);if(r.type===`set`)return YC(r.valueType,n);if(r.type===`lazy`)return YC(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return YC(r.innerType,n);if(r.type===`intersection`)return YC(r.left,n)||YC(r.right,n);if(r.type===`record`||r.type===`map`)return YC(r.keyType,n)||YC(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:YC(r.in,n)||YC(r.out,n);if(r.type===`object`){for(let e in r.shape)if(YC(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(YC(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(YC(e,n))return!0;return!!(r.rest&&YC(r.rest,n))}return!1}var XC=(e,t={})=>n=>{let r=LC({...n,processors:t});return zC(e,r),VC(r,e),JC(r,e)},ZC=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=LC({...i??{},target:a,io:t,processors:n});return zC(e,o),VC(o,e),JC(o,e)},QC=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},$C=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},ew=(e,t)=>{QC(e,`minimum`,t),$C(e,`maximum`,t)},tw=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},nw=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},rw=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},iw=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},aw=(e,t)=>QC(e,`minimum`,t.minimum),ow=(e,t)=>$C(e,`maximum`,t.maximum),sw=e=>(t,n)=>{iw(t,n.format);let[r,i]=e[n.format];QC(t,`minimum`,r),$C(t,`maximum`,i)},cw={greater_than:(e,t)=>QC(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>$C(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>tw(e,t.value),number_format:sw(Iv),bigint_format:sw(Lv),min_length:aw,max_length:ow,length_equals:(e,t)=>ew(e,t.length),min_size:aw,max_size:ow,size_equals:(e,t)=>ew(e,t.size),string_format:(e,t)=>{iw(e,t.format),t.pattern&&nw(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>rw(e,t.mime)};function lw(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)cw[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&QC(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&QC(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&$C(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&$C(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&tw(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&rw(t,i.mime);for(let e of i.patterns??[])nw(t,e);return t}var uw={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},dw=new Map([[Dx,_b],[kx,vb]]),fw=e=>dw.get(e)??e,pw=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=lw(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=uw[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(fw);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},mw=(e,t,n,r)=>{n.not={}},hw=(e,t,n,r)=>{let i=e._zod.def,a=cv(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},gw=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(RC(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(RC(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},_w=(e,t,n,r)=>{RC(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},vw=(e,t,n,r)=>{RC(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},yw=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=lw(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=zC(a.element,t,{...r,path:[...r.path,`items`]})};function bw(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?bw(t.out):t.type===`catch`?bw(t.innerType):e._zod.optin}var xw=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&RC(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)hv(i.properties,e,zC(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?bw(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=zC(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Sw=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>zC(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Cw=(e,t,n,r)=>{let i=e._zod.def,a=zC(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=zC(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},ww=(e,t,n,r)=>{let i=e._zod.def,a=zC(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Tw=(e,t,n,r)=>{let i=e._zod.def;zC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ew=Symbol();function Dw(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(RC(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Ew):JSON.parse(o)}var Ow=(e,t,n,r)=>{let i=e._zod.def;zC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Dw(i.defaultValue,e,t,n,r);o!==Ew&&(n.default=o)},kw=(e,t,n,r)=>{let i=e._zod.def;zC(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Dw(i.defaultValue,e,t,n,r);o!==Ew&&(n._prefault=o)},Aw=(e,t,n,r)=>{let i=e._zod.def;zC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{RC(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},jw=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;zC(o,t,r);let s=t.seen.get(e);s.ref=o},Mw=(e,t,n,r)=>{let i=e._zod.def;zC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Nw=(e,t,n,r)=>{let i=e._zod.def;zC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Pw=new WeakSet([Object.prototype,Error.prototype]);function Fw(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var Iw=$(`ZodError`,(e,t)=>{jy.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Pw.has(n)||(Pw.add(n),Fw(n,`format`,e=>t=>Py(e,t)),Fw(n,`flatten`,e=>t=>Ny(e,t)),Fw(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,uv,2)}),Fw(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,uv,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Lw=Iy(Iw),Rw=Ly(Iw),zw=Ry(Iw),Bw=By(Iw),Vw=Ky(Iw),Hw=qy(Iw),Uw=Jy(Iw),Ww=Yy(Iw),Gw=Xy(Iw),Kw=Zy(Iw),qw=Qy(Iw),Jw=$y(Iw);function Yw(){wy.localeError||Ty(IS())}function Xw(){wy.memoizer||Ty({memoizer:NS()})}var Zw=$(`ZodType`,(e,t)=>(Yw(),Gb.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Sv(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Mv(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(lE(e,t))},superRefine(e,t){return this.check(uE(e,t))},overwrite(e){return this.check(EC(e))},optional(){return GT(this)},exactOptional(){return qT(this)},nullable(){return YT(this)},nullish(){return GT(YT(this))},nonoptional(e){return tE(this,e)},array(){return AT(this)},or(e){return FT([this,e])},and(e){return LT(this,e)},transform(e){return aE(this,UT(e))},default(e){return ZT(this,e)},prefault(e){return $T(this,e)},catch(e){return rE(this,e)},pipe(e){return aE(this,e)},readonly(){return sE(this)},describe(e){let t=this.clone();return BS.add(t,{description:e}),t},meta(...e){if(e.length===0)return BS.get(this);let t=this.clone();return BS.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return sy(this,`~standard`,{...Jb(this),jsonSchema:{input:ZC(this,`input`),output:ZC(this,`output`)}})},set"~standard"(e){oy(this,`~standard`,e)},parse:function e(t,n){return Lw(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Rw(this,t,n,{callee:e})},safeParse(e,t){return zw(this,e,t)},async safeParseAsync(e,t){return Bw(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){oy(this,`spa`,e)},validate(e,t){return Uy(this,e,t)},validateAsync(e,t){return Gy(this,e,t)},encode:function e(t,n){return Vw(this,t,n,{callee:e})},decode:function e(t,n){return Hw(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Uw(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ww(this,t,n,{callee:e})},safeEncode(e,t){return Gw(this,e,t)},safeDecode(e,t){return Kw(this,e,t)},async safeEncodeAsync(e,t){return qw(this,e,t)},async safeDecodeAsync(e,t){return Jw(this,e,t)},toJSONSchema(e){return XC(this,{})(e)},get description(){return BS.get(this)?.description},get _def(){return this._zod.def}}),Qw=$(`_ZodString`,(e,t)=>{Yb.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pw(e,t,n,r)},cy({format:e=>lw(e).format??null,minLength:e=>lw(e).minimum??null,maxLength:e=>lw(e).maximum??null},{regex(...e){return this.check(bC(...e))},includes(...e){return this.check(CC(...e))},startsWith(...e){return this.check(wC(...e))},endsWith(...e){return this.check(TC(...e))},min(...e){return this.check(vC(...e))},max(...e){return this.check(_C(...e))},length(...e){return this.check(yC(...e))},nonempty(...e){return this.check(vC(1,...e))},lowercase(e){return this.check(xC(e))},uppercase(e){return this.check(SC(e))},trim(){return this.check(OC())},normalize(...e){return this.check(DC(...e))},toLowerCase(){return this.check(kC())},toUpperCase(){return this.check(AC())},slugify(){return this.check(jC())}})),$w=$(`ZodString`,(e,t)=>{Yb.init(e,t),Qw.init(e,t)},{email(e){return this.check(US(oT,e))},url(e){return this.check(YS(lT,e))},jwt(e){return this.check(uC(wT,e))},emoji(e){return this.check(XS(uT,e))},guid(e){return this.check(WS(sT,e))},uuid(e){return this.check(GS(cT,e))},uuidv4(e){return this.check(KS(cT,e))},uuidv6(e){return this.check(qS(cT,e))},uuidv7(e){return this.check(JS(cT,e))},nanoid(e){return this.check(ZS(dT,e))},cuid(e){return this.check(QS(fT,e))},cuid2(e){return this.check($S(pT,e))},ulid(e){return this.check(eC(mT,e))},base64(e){return this.check(sC(xT,e))},base64url(e){return this.check(cC(ST,e))},xid(e){return this.check(tC(hT,e))},ksuid(e){return this.check(nC(gT,e))},ipv4(e){return this.check(rC(_T,e))},ipv6(e){return this.check(iC(vT,e))},cidrv4(e){return this.check(aC(yT,e))},cidrv6(e){return this.check(oC(bT,e))},e164(e){return this.check(lC(CT,e))},datetime(e){return this.check(dC(nT,e))},date(e){return this.check(fC(rT,e))},time(e){return this.check(pC(iT,e))},duration(e){return this.check(mC(aT,e))}});function eT(e){return HS($w,e)}var tT=$(`ZodStringFormat`,(e,t)=>{Xb.init(e,t),Qw.init(e,t)}),nT=$(`ZodISODateTime`,(e,t)=>{hx.init(e,t),tT.init(e,t)}),rT=$(`ZodISODate`,(e,t)=>{gx.init(e,t),tT.init(e,t)}),iT=$(`ZodISOTime`,(e,t)=>{_x.init(e,t),tT.init(e,t)}),aT=$(`ZodISODuration`,(e,t)=>{vx.init(e,t),tT.init(e,t)}),oT=$(`ZodEmail`,(e,t)=>{$b.init(e,t),tT.init(e,t)}),sT=$(`ZodGUID`,(e,t)=>{Zb.init(e,t),tT.init(e,t)}),cT=$(`ZodUUID`,(e,t)=>{Qb.init(e,t),tT.init(e,t)}),lT=$(`ZodURL`,(e,t)=>{sx.init(e,t),tT.init(e,t)}),uT=$(`ZodEmoji`,(e,t)=>{cx.init(e,t),tT.init(e,t)}),dT=$(`ZodNanoID`,(e,t)=>{lx.init(e,t),tT.init(e,t)}),fT=$(`ZodCUID`,(e,t)=>{ux.init(e,t),tT.init(e,t)}),pT=$(`ZodCUID2`,(e,t)=>{dx.init(e,t),tT.init(e,t)}),mT=$(`ZodULID`,(e,t)=>{fx.init(e,t),tT.init(e,t)}),hT=$(`ZodXID`,(e,t)=>{px.init(e,t),tT.init(e,t)}),gT=$(`ZodKSUID`,(e,t)=>{mx.init(e,t),tT.init(e,t)}),_T=$(`ZodIPv4`,(e,t)=>{yx.init(e,t),tT.init(e,t)}),vT=$(`ZodIPv6`,(e,t)=>{Sx.init(e,t),tT.init(e,t)}),yT=$(`ZodCIDRv4`,(e,t)=>{Cx.init(e,t),tT.init(e,t)}),bT=$(`ZodCIDRv6`,(e,t)=>{Tx.init(e,t),tT.init(e,t)}),xT=$(`ZodBase64`,(e,t)=>{Ox.init(e,t),tT.init(e,t)}),ST=$(`ZodBase64URL`,(e,t)=>{jx.init(e,t),tT.init(e,t)}),CT=$(`ZodE164`,(e,t)=>{Mx.init(e,t),tT.init(e,t)}),wT=$(`ZodJWT`,(e,t)=>{Px.init(e,t),tT.init(e,t)}),TT=$(`ZodUnknown`,(e,t)=>{Fx.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ET(){return hC(TT)}var DT=$(`ZodNever`,(e,t)=>{Ix.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mw(e,t,n,r)});function OT(e){return gC(DT,e)}var kT=$(`ZodArray`,(e,t)=>{Xw(),Bx.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yw(e,t,n,r),e.element=t.element},{min(e,t){return this.check(vC(e,t))},nonempty(e){return this.check(vC(1,e))},max(e,t){return this.check(_C(e,t))},length(e,t){return this.check(yC(e,t))},unwrap(){return this.element}});function AT(e,t){return MC(kT,e,t)}var jT=$(`ZodObject`,(e,t)=>{Xw(),Kx.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xw(e,t,n,r),hy(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return zT(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Sv(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Sv(this._zod.def,{catchall:ET()}))},loose(){return this.clone(Sv(this._zod.def,{catchall:ET()}))},strict(){return this.clone(Sv(this._zod.def,{catchall:OT()}))},strip(){return this.clone(Sv(this._zod.def,{catchall:void 0}))},extend(e){return Vv(this,e)},safeExtend(e){return Uv(this,e)},merge(e){return Wv(this,e)},pick(e){return Rv(this,e)},omit(e){return Bv(this,e)},partial(...e){return Gv(WT,this,e[0])},exactPartial(...e){return Gv(KT,this,e[0],`exactPartial`)},required(...e){return Kv(eE,this,e[0])}});function MT(e,t){return new jT({type:`object`,shape:e??{},...Nv(t)})}function NT(e,t){return new jT({type:`object`,shape:e,catchall:ET(),...Nv(t)})}var PT=$(`ZodUnion`,(e,t)=>{Jx.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sw(e,t,n,r),e.options=t.options});function FT(e,t){return new PT({type:`union`,options:e,...Nv(t)})}var IT=$(`ZodIntersection`,(e,t)=>{Yx.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cw(e,t,n,r)});function LT(e,t){return new IT({type:`intersection`,left:e,right:t})}var RT=$(`ZodEnum`,(e,t)=>{Qx.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hw(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new RT({...t,checks:[],...Nv(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new RT({...t,checks:[],...Nv(r),entries:i})}});function zT(e,t){return new RT({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Nv(t)})}var BT=$(`ZodLiteral`,(e,t)=>{$x.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gw(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function VT(e,t){return new BT({type:`literal`,values:Array.isArray(e)?e:[e],...Nv(t)})}var HT=$(`ZodTransform`,(e,t)=>{Xw(),eS.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vw(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Cy(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(iy(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(iy(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function UT(e){return new HT({type:`transform`,transform:e})}var WT=$(`ZodOptional`,(e,t)=>{nS.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function GT(e){return new WT({type:`optional`,innerType:e})}var KT=$(`ZodExactOptional`,(e,t)=>{rS.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qT(e){return new KT({type:`optional`,innerType:e})}var JT=$(`ZodNullable`,(e,t)=>{iS.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ww(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function YT(e){return new JT({type:`nullable`,innerType:e})}var XT=$(`ZodDefault`,(e,t)=>{aS.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ow(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ZT(e,t){return new XT({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():kv(t)}})}var QT=$(`ZodPrefault`,(e,t)=>{sS.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $T(e,t){return new QT({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():kv(t)}})}var eE=$(`ZodNonOptional`,(e,t)=>{cS.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function tE(e,t){return new eE({type:`nonoptional`,innerType:e,...Nv(t)})}var nE=$(`ZodCatch`,(e,t)=>{dS.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Aw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function rE(e,t){return new nE({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:_y(t)})}var iE=$(`ZodPipe`,(e,t)=>{fS.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jw(e,t,n,r),e.in=t.in,e.out=t.out});function aE(e,t){return new iE({type:`pipe`,in:e,out:t})}var oE=$(`ZodReadonly`,(e,t)=>{mS.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sE(e){return new oE({type:`readonly`,innerType:e})}var cE=$(`ZodCustom`,(e,t)=>{gS.init(e,t),Zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_w(e,t,n,r)});function lE(e,t={}){return NC(cE,e,t)}function uE(e,t){return PC(e,t)}var dE=NT({frame:eT(),session:eT(),agent:eT(),tag:eT(),claimedAt:eT(),expiresAt:eT()});function fE(e,t){return t===e||t.startsWith(`${e}/`)}NT({version:VT(1),claims:AT(dE)});var pE=class extends Error{reason;constructor(e){super(`The waiting edit was ${e}.`),this.reason=e,this.name=`WaitDropped`}},mE=1e3,hE=ue()(()=>({edits:[]})),gE=new Set,_E=1;function vE(){return fe(hE,e=>e.edits)}function yE(e,t,{live:n=yl,replace:r,dropWhen:i}){r&&wE(e,r);let a=()=>Object.values(n.getState().claims).filter(t=>e.some(e=>fE(e,t.frame))),o=a();return o.length===0?null:CE({label:t,refs:e,replace:r,dropWhen:i,live:n,holders:o.map(({frame:e,tag:t,claimedAt:n})=>({frame:e,tag:t,claimedAt:n})),ready:()=>n.getState().connected&&a().length===0})}function bE(e,t,{live:n=yl,replace:r,dropWhen:i}={}){let{frame:a,tag:o,claimedAt:s,expiresAt:c}=e.details;if(typeof a!=`string`)return Promise.reject(e);let l={frame:a,tag:typeof o==`string`?o:a,claimedAt:typeof s==`string`?s:new Date().toISOString()},u=typeof c==`string`?Date.parse(c):NaN,d=Date.now(),f=!1;return r&&wE([a],r),CE({label:t,refs:[a],replace:r,dropWhen:i,live:n,holders:[l],ready:()=>{let{claims:e,connected:t}=n.getState();if(a in e&&(f=!0),!t||a in e)return!1;let r=Date.now();return f||r>=u||r-d>=2e3}})}async function xE(e,t,n,r={}){let i=yE(e,t,r);for(i&&await i;;)try{return await n()}catch(e){if(!(e instanceof jl)||e.code!==`frame-claimed`)throw e;await bE(e,t,r)}}function SE(){for(let e of[...gE])TE(e,new pE(`cancelled`))}function CE({label:e,refs:t,replace:n,dropWhen:r,live:i,holders:a,ready:o}){return new Promise((s,c)=>{let l={id:_E++,label:e,holders:a},u=()=>{r?.(i.getState())?TE(p,new pE(`cancelled`)):o()&&(TE(p),s())},d=i.subscribe(u),f=setInterval(u,mE),p={edit:l,refs:t,replace:n,reject:c,stop:()=>{d(),clearInterval(f)}};gE.add(p),hE.setState(e=>({edits:[...e.edits,l]})),u()})}function wE(e,t){for(let n of[...gE])n.replace===t&&n.refs.every(t=>e.includes(t))&&TE(n,new pE(`replaced`))}function TE(e,t){gE.delete(e)&&(e.stop(),hE.setState(t=>({edits:t.edits.filter(t=>t!==e.edit)})),t&&e.reject(t))}function EE(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function DE(e){if(e.length===0)return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t,y:n,width:r-t,height:i-n}}var OE=2e3,kE=ue()(()=>({byRef:{}}));function AE(e){return fe(kE,t=>t.byRef[e]?.box)}function jE(e){return NE(e,fe(kE,e=>e.byRef))}function ME(e){return NE(e,kE.getState().byRef)}function NE(e,t){return e.map(e=>{let n=t[e.ref];return n?{...e,box:n.box}:e})}function PE(e){VE(Object.keys(e),t=>{let n=e[t];return n&&{box:n}})}var FE=new Map;async function IE(e,t,n,r=fetch){if(Object.keys(t).length===0)return!0;let i={...t},a={...n};for(let e of Object.keys(t)){let t=FE.get(e);if(t)for(let[e,n]of Object.entries(t.owner.boxes)){if(e in i)continue;i[e]=n;let t=FE.get(e)?.box;t&&(a[e]=t)}}for(let e of Object.keys(i)){let t=FE.get(e)?.box;t&&(a[e]=t)}let o=Object.keys(i),s=new Map(Object.entries(i).map(([e,t])=>[e,{box:t}]));VE(o,e=>s.get(e));let c=()=>{let{byRef:e}=kE.getState();VE(o.filter(t=>e[t]===s.get(t)),()=>void 0)},l={boxes:i},u=()=>{for(let e of o){let t=a[e];t&&FE.set(e,{box:t,owner:l})}},d=()=>{for(let e of o)FE.get(e)?.owner===l&&FE.delete(e)};u();try{await xE(o,LE(i,a),async()=>{d();try{return await Ml(`/api/frames/boxes`,{page:e,boxes:HE(i),expected:HE(a)},`POST`,r)}catch(e){throw u(),e}},{replace:`boxes`})}catch{return d(),c(),!1}return setTimeout(c,OE),!0}function LE(e,t){return Object.entries(e).some(([e,n])=>{let r=t[e];return r&&(r.width!==n.width||r.height!==n.height)})?`resize`:`move`}function RE(e){VE(e,()=>void 0)}function zE(e){return e.subscribe((e,t)=>{e.board&&e.board!==t.board&&BE(e.board)})}function BE(e){let t=new Map(e.projects.flatMap(e=>e.pages.flatMap(e=>e.frames.map(e=>[e.ref,e.box])))),{byRef:n}=kE.getState(),r=Object.entries(n).filter(([e,n])=>{let r=t.get(e);return r!==void 0&&!EE(r,n.box)});r.length!==Object.keys(n).length&&kE.setState({byRef:Object.fromEntries(r)})}function VE(e,t){if(e.length===0)return;let n={...kE.getState().byRef};for(let r of e){let e=t(r);e?n[r]=e:delete n[r]}kE.setState({byRef:n})}function HE(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e.slice(e.lastIndexOf(`/`)+1),t]))}function UE(e=fetch){let t=(t,n)=>Ml(t,n,`POST`,e),n=(e,n,r,i)=>xE(e,n,()=>t(r,i));return{addProject:e=>t(`/api/project/add`,{name:e}),renameProject:(e,n)=>t(`/api/project/rename`,{ref:e,name:n}),duplicateProject:e=>t(`/api/project/duplicate`,{ref:e}),deleteProject:e=>t(`/api/project/delete`,{ref:e}),addPage:(e,n)=>t(`/api/page/add`,{ref:e,index:n}),duplicatePage:e=>t(`/api/page/duplicate`,{ref:e}),renamePage:(e,t)=>n([e],`rename`,`/api/page/rename`,{ref:e,name:t}),movePage:(e,n)=>t(`/api/page/move`,{ref:e,index:n}),deletePage:e=>n([e],`delete`,`/api/page/delete`,{ref:e}),addFrame:(e,n,r,i)=>t(`/api/frame/add`,{ref:e,size:n,x:r,y:i}),duplicateFrames:e=>t(`/api/frame/duplicate`,{refs:e}),renameFrame:(e,t)=>n([e],`rename`,`/api/frame/rename`,{ref:e,name:t}),orderFrame:(e,n)=>t(`/api/frame/order`,{ref:e,index:n}),flagFrames:(e,n,r)=>t(`/api/frame/flag`,{refs:e,flag:n,on:r}),deleteFrames:e=>n(e,`delete`,`/api/frame/delete`,{refs:e}),copyFrames:e=>t(`/api/clipboard/copy`,{refs:e}),cutFrames:e=>n(e,`cut`,`/api/clipboard/cut`,{refs:e}),pasteFrames:(e,n)=>t(`/api/clipboard/paste`,{ref:e,at:n}),undo:()=>t(`/api/undo`,{}),redo:()=>t(`/api/redo`,{})}}var WE=UE();function GE(e,t){return e.toLowerCase()===t.toLowerCase()}function KE(e,t){let n=new Set([...t].map(e=>e.toLowerCase()));if(!n.has(e.toLowerCase()))return e;for(let t=2;;t++){let r=`${e}-${t}`;if(!n.has(r.toLowerCase()))return r}}var qE=ue()(()=>({ref:null}));function JE(){return fe(qE,e=>e.ref)}function YE(e){qE.setState({ref:e})}function XE(){qE.setState({ref:null})}function ZE(e){return t=>{t instanceof pE||E_.add({title:e,description:t instanceof Error?t.message:String(t),type:`error`})}}function QE(e){for(let t=e.length+1;;t++){let n=`page-${t}`;if(!e.some(e=>GE(e,n)))return n}}async function $E(e,t,{current:n,navigate:r,calls:i=WE}){try{let a=await i.renamePage(e.ref,t);e.name===n&&r(z(e.project,a.name))}catch(t){ZE(`Couldn't rename ${e.name}`)(t)}}async function eD(e,t,{current:n,navigate:r,calls:i=WE}){let a=t.filter(t=>t.ref!==e.ref),o=a[e.index]??a[e.index-1];try{await i.deletePage(e.ref)}catch(t){ZE(`Couldn't delete ${e.name}`)(t);return}e.name===n&&r(o?z(e.project,o.name):`/p/${encodeURIComponent(e.project)}`)}function tD(e,t){let[,n]=Rr();(0,y.useEffect)(()=>{let r=()=>yl.getState().board?.projects.find(t=>t.name===e)?.pages??[],i=()=>r().find(e=>e.name===t),a=()=>yl.getState().canWrite,o=()=>a()&&i()!==void 0,s=e=>n(z(e.project,e.name)),c=be([{id:`page.new`,label:`Add page`,group:`page`,command:{label:`Add page`,icon:Ft},enabled:a,run:()=>{let t=r().map(e=>e.name),n=i();WE.addPage(`${e}/${QE(t)}`,n?n.index+1:void 0).then(e=>{s(e),YE(e.ref)},ZE(`Couldn't add a page`))}},{id:`page.duplicate`,label:`Duplicate page`,group:`page`,command:{label:`Duplicate page`,icon:kt},enabled:o,run:()=>{let e=i();e&&WE.duplicatePage(e.ref).then(s,ZE(`Couldn't duplicate ${e.name}`))}},{id:`page.rename`,label:`Rename page`,group:`page`,command:{label:`Rename page`,icon:On},enabled:o,run:()=>{let e=i();e&&YE(e.ref)}},{id:`page.delete`,label:`Delete page`,group:`page`,command:{label:`Delete page`,icon:ur},enabled:o,run:()=>{let e=i();e&&eD(e,r(),{current:e.name,navigate:n})}}]),l=yl.subscribe((e,t)=>{(e.canWrite!==t.canWrite||e.board!==t.board)&&xe()});return()=>{l(),c()}},[e,t,n])}var nD=1024;function rD(e){return ue()(()=>({mode:`edit`,tool:`move`,hideUi:e<nD}))}var iD=rD(window.innerWidth);function aD(e){return fe(iD,e)}function oD(){return ue()(()=>({page:null,frames:[]}))}function sD(e,t,n){e.setState({page:t,frames:[...new Set(n)],element:null})}function cD(e,t,n){e.setState({page:t,frames:[n.frame],element:n})}function lD(e,t,n){let{page:r,frames:i}=e.getState();if(r!==t){sD(e,t,[n]);return}let a=i.includes(n)?i.filter(e=>e!==n):[...i,n];e.setState({page:a.length===0?null:t,frames:a,element:null})}function uD(e){let{page:t,frames:n,element:r}=e.getState();(t!==null||n.length!==0||r)&&e.setState({page:null,frames:[],element:null})}function dD(e,t){let{page:n,frames:r}=e.getState();if(n===null)return;let i=new Set(t.projects.flatMap(e=>e.pages).find(e=>e.ref===n)?.frames.filter(e=>!e.hidden).map(e=>e.ref)),a=r.filter(e=>i.has(e));a.length!==r.length&&(a.length===0?uD(e):e.setState({frames:a,element:null}))}function fD(e,t,n,r){e.getState().page!==t&&uD(e);let i=n.getState().board;i&&dD(e,i);let a=n.subscribe((t,n)=>{t.board&&t.board!==n.board&&dD(e,t.board)}),o=r.subscribe(t=>{t.mode===`play`&&uD(e)});return()=>{o(),a()}}var pD=new Map;function mD(e){pD.set(e,(pD.get(e)??0)+1);let t=!1;return()=>{t||(t=!0,pD.set(e,(pD.get(e)??1)-1))}}var hD=new Map;function gD(e,t){let n=(hD.get(e)??[]).filter(e=>e!==t);hD.set(e,[...n,t].slice(-100))}function _D(e,t){return(pD.get(e)??0)>0||(pD.get(null)??0)>0||t!=null&&(hD.get(e)?.includes(t)??!1)}function vD(e,t){let{page:n,element:r}=e.getState();if(!n||!r||_D(r.frame))return;let i=t(r.frame);i!==null&&i!==r.hash&&sD(e,n,[r.frame])}function yD(e,t){let{page:n,element:r}=e.getState();if(!n||!r||_D(r.frame))return;let i=t(r.frame);i!==null&&i!==r.hash&&!_D(r.frame,i)&&sD(e,n,[r.frame])}var bD=oD();function xD(e){return fe(bD,e)}var SD=null,CD=null,wD=1,TD=new Set,ED=new Set,DD=new Set,OD={zoom:()=>wD,attached:()=>SD!==null,page:()=>CD,onZoom:e=>MD(TD,e),onAttach:e=>MD(ED,e),onHandMove:e=>MD(DD,e),zoomBy:e=>SD?.zoomBy(e),zoomTo:e=>SD?.zoomTo(e),fit:()=>SD?.fit(),fitTo:e=>SD?.fitTo(e),panBy:(e,t)=>SD?.panBy(e,t),centerOn:e=>SD?.centerOn(e)};function kD(e,t){return SD=e,CD=t,ND(ED),()=>{SD===e&&(SD=null,CD=null,ND(ED))}}function AD(){ND(DD)}function jD(e){e!==wD&&(wD=e,ND(TD))}function MD(e,t){return e.add(t),()=>{e.delete(t)}}function ND(e){for(let t of e)t()}var PD=2,FD=40,ID=200,LD=[{name:`left`,key:`ArrowLeft`,dx:-1,dy:0},{name:`right`,key:`ArrowRight`,dx:1,dy:0},{name:`up`,key:`ArrowUp`,dx:0,dy:-1},{name:`down`,key:`ArrowDown`,dx:0,dy:1}];function RD(){(0,y.useEffect)(()=>{let e=be(BD()),t=iD.subscribe(xe),n=bD.subscribe(xe),r=OD.onAttach(xe);return()=>{r(),n(),t(),e()}},[])}function zD(){let{page:e,frames:t}=bD.getState(),n=yl.getState().board?.projects.flatMap(e=>e.pages).find(t=>t.ref===e)?.frames.filter(e=>t.includes(e.ref));return ME(n??[])}function BD(){let e=()=>iD.getState(),t=e=>iD.setState(e),n=e=>({...e,group:`view`,enabled:OD.attached}),r=t=>()=>OD.attached()&&e().mode===`edit`&&t(bD.getState().frames.length);return[{id:`tool.move`,label:`Move`,group:`tool`,keys:[`v`],run:()=>t({tool:`move`,mode:`edit`}),checked:()=>e().mode===`edit`&&e().tool===`move`},{id:`tool.hand`,label:`Hand`,group:`tool`,keys:[`h`],run:()=>t({tool:`hand`,mode:`edit`}),checked:()=>e().mode===`edit`&&e().tool===`hand`},{id:`mode.edit`,label:`Edit`,group:`mode`,command:{label:`Switch to Edit`,icon:An},run:()=>t({mode:`edit`}),checked:()=>e().mode===`edit`},{id:`mode.play`,label:`Play`,group:`mode`,command:{label:`Switch to Play`,icon:Mn},run:()=>t({mode:`play`}),checked:()=>e().mode===`play`},{id:`mode.exitPlay`,label:`Exit Play`,group:`mode`,keys:[`Escape`],enabled:()=>e().mode===`play`,run:()=>{document.activeElement instanceof HTMLIFrameElement&&document.activeElement.blur(),t({mode:`edit`})}},{id:`view.hideUi`,label:`Hide UI`,group:`view`,command:{label:`Hide UI`,icon:En},keys:[`$mod+Backslash`],run:()=>t({hideUi:!e().hideUi}),checked:()=>e().hideUi},n({id:`view.zoomIn`,label:`Zoom in`,command:{label:`Zoom in`,icon:Sr},keys:[`$mod+Equal`],run:()=>OD.zoomBy(PD)}),n({id:`view.zoomOut`,label:`Zoom out`,command:{label:`Zoom out`,icon:wr},keys:[`$mod+Minus`],run:()=>OD.zoomBy(1/PD)}),n({id:`view.zoomToFit`,label:`Zoom to fit`,command:{label:`Zoom to fit`,icon:fn},keys:[`Shift+Digit1`],run:OD.fit}),{id:`view.zoomToSelection`,label:`Zoom to selection`,group:`view`,command:{label:`Zoom to selection`,icon:Hn},keys:[`Shift+Digit2`],enabled:r(e=>e>0),run:()=>OD.fitTo(zD().map(e=>e.box))},...LD.flatMap(({name:e,key:t,dx:n,dy:i})=>[{id:`view.pan.${e}`,label:`Pan ${e}`,group:`view`,keys:[t],enabled:r(e=>e===0),run:()=>OD.panBy(n*FD,i*FD)},{id:`view.pan.${e}Far`,label:`Pan ${e} further`,group:`view`,keys:[`Shift+${t}`],enabled:r(e=>e===0),run:()=>OD.panBy(n*ID,i*ID)}]),{id:`frame.copyPng`,label:`Copy as PNG`,group:`frame`,command:{label:`Copy as PNG`,icon:kt},keys:[`$mod+Shift+KeyC`],enabled:r(e=>e===1),run:()=>{let[e]=zD();if(!e)return;let t=ev(e.ref);sv(e.ref,t).then(()=>E_.add({title:`Copied ${e.name}`,description:`PNG on the clipboard, in the ${t} theme.`,type:`success`}),ZE(`Couldn't copy ${e.name}`))}},n({id:`view.zoom50`,label:`Zoom to 50%`,run:()=>OD.zoomTo(.5)}),n({id:`view.zoom100`,label:`Zoom to 100%`,run:()=>OD.zoomTo(1)}),n({id:`view.zoom200`,label:`Zoom to 200%`,run:()=>OD.zoomTo(2)})]}var VD={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function HD(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),VD.hasOwnProperty(t)?{space:VD[t],local:e}:e}function UD(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function WD(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function GD(e){var t=HD(e);return(t.local?WD:UD)(t)}function KD(){}function qD(e){return e==null?KD:function(){return this.querySelector(e)}}function JD(e){typeof e!=`function`&&(e=qD(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new Ik(r,this._parents)}function YD(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function XD(){return[]}function ZD(e){return e==null?XD:function(){return this.querySelectorAll(e)}}function QD(e){return function(){return YD(e.apply(this,arguments))}}function $D(e){e=typeof e==`function`?QD(e):ZD(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new Ik(r,i)}function eO(e){return function(){return this.matches(e)}}function tO(e){return function(t){return t.matches(e)}}var nO=Array.prototype.find;function rO(e){return function(){return nO.call(this.children,e)}}function iO(){return this.firstElementChild}function aO(e){return this.select(e==null?iO:rO(typeof e==`function`?e:tO(e)))}var oO=Array.prototype.filter;function sO(){return Array.from(this.children)}function cO(e){return function(){return oO.call(this.children,e)}}function lO(e){return this.selectAll(e==null?sO:cO(typeof e==`function`?e:tO(e)))}function uO(e){typeof e!=`function`&&(e=eO(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Ik(r,this._parents)}function dO(e){return Array(e.length)}function fO(){return new Ik(this._enter||this._groups.map(dO),this._parents)}function pO(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}pO.prototype={constructor:pO,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function mO(e){return function(){return e}}function hO(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new pO(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function gO(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new pO(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function _O(e){return e.__data__}function vO(e,t){if(!arguments.length)return Array.from(this,_O);var n=t?gO:hO,r=this._parents,i=this._groups;typeof e!=`function`&&(e=mO(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=yO(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new Ik(o,r),o._enter=s,o._exit=c,o}function yO(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function bO(){return new Ik(this._exit||this._groups.map(dO),this._parents)}function xO(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function SO(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new Ik(s,this._parents)}function CO(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function wO(e){e||=TO;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new Ik(i,this._parents).order()}function TO(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function EO(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function DO(){return Array.from(this)}function OO(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function kO(){let e=0;for(let t of this)++e;return e}function AO(){return!this.node()}function jO(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function MO(e){return function(){this.removeAttribute(e)}}function NO(e){return function(){this.removeAttributeNS(e.space,e.local)}}function PO(e,t){return function(){this.setAttribute(e,t)}}function FO(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function IO(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function LO(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function RO(e,t){var n=HD(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?NO:MO:typeof t==`function`?n.local?LO:IO:n.local?FO:PO)(n,t))}function zO(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function BO(e){return function(){this.style.removeProperty(e)}}function VO(e,t,n){return function(){this.style.setProperty(e,t,n)}}function HO(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function UO(e,t,n){return arguments.length>1?this.each((t==null?BO:typeof t==`function`?HO:VO)(e,t,n??``)):WO(this.node(),e)}function WO(e,t){return e.style.getPropertyValue(t)||zO(e).getComputedStyle(e,null).getPropertyValue(t)}function GO(e){return function(){delete this[e]}}function KO(e,t){return function(){this[e]=t}}function qO(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function JO(e,t){return arguments.length>1?this.each((t==null?GO:typeof t==`function`?qO:KO)(e,t)):this.node()[e]}function YO(e){return e.trim().split(/^|\s+/)}function XO(e){return e.classList||new ZO(e)}function ZO(e){this._node=e,this._names=YO(e.getAttribute(`class`)||``)}ZO.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function QO(e,t){for(var n=XO(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function $O(e,t){for(var n=XO(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function ek(e){return function(){QO(this,e)}}function tk(e){return function(){$O(this,e)}}function nk(e,t){return function(){(t.apply(this,arguments)?QO:$O)(this,e)}}function rk(e,t){var n=YO(e+``);if(arguments.length<2){for(var r=XO(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?nk:t?ek:tk)(n,t))}function ik(){this.textContent=``}function ak(e){return function(){this.textContent=e}}function ok(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function sk(e){return arguments.length?this.each(e==null?ik:(typeof e==`function`?ok:ak)(e)):this.node().textContent}function ck(){this.innerHTML=``}function lk(e){return function(){this.innerHTML=e}}function uk(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function dk(e){return arguments.length?this.each(e==null?ck:(typeof e==`function`?uk:lk)(e)):this.node().innerHTML}function fk(){this.nextSibling&&this.parentNode.appendChild(this)}function pk(){return this.each(fk)}function mk(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function hk(){return this.each(mk)}function gk(e){var t=typeof e==`function`?e:GD(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function _k(){return null}function vk(e,t){var n=typeof e==`function`?e:GD(e),r=t==null?_k:typeof t==`function`?t:qD(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function yk(){var e=this.parentNode;e&&e.removeChild(this)}function bk(){return this.each(yk)}function xk(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Sk(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ck(e){return this.select(e?Sk:xk)}function wk(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function Tk(e){return function(t){e.call(this,t,this.__data__)}}function Ek(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Dk(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function Ok(e,t,n){return function(){var r=this.__on,i,a=Tk(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function kk(e,t,n){var r=Ek(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}}else{for(s=t?Ok:Dk,i=0;i<a;++i)this.each(s(r[i],t,n));return this}}function Ak(e,t,n){var r=zO(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function jk(e,t){return function(){return Ak(this,e,t)}}function Mk(e,t){return function(){return Ak(this,e,t.apply(this,arguments))}}function Nk(e,t){return this.each((typeof t==`function`?Mk:jk)(e,t))}function*Pk(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var Fk=[null];function Ik(e,t){this._groups=e,this._parents=t}function Lk(){return new Ik([[document.documentElement]],Fk)}function Rk(){return this}Ik.prototype=Lk.prototype={constructor:Ik,select:JD,selectAll:$D,selectChild:aO,selectChildren:lO,filter:uO,data:vO,enter:fO,exit:bO,join:xO,merge:SO,selection:Rk,order:CO,sort:wO,call:EO,nodes:DO,node:OO,size:kO,empty:AO,each:jO,attr:RO,style:UO,property:JO,classed:rk,text:sk,html:dk,raise:pk,lower:hk,append:gk,insert:vk,remove:bk,clone:Ck,datum:wk,on:kk,dispatch:Nk,[Symbol.iterator]:Pk};function zk(e){return typeof e==`string`?new Ik([[document.querySelector(e)]],[document.documentElement]):new Ik([[e]],Fk)}function Bk(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Vk(e,t){if(e=Bk(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var Hk={value:()=>{}};function Uk(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new Wk(n)}function Wk(e){this._=e}function Gk(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Wk.prototype=Uk.prototype={constructor:Wk,on:function(e,t){var n=this._,r=Gk(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=Kk(n[i],e.name)))return i}else{if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=qk(n[i],e.name,t);else if(t==null)for(i in n)n[i]=qk(n[i],e.name,null);return this}},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Wk(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function Kk(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function qk(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Hk,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Jk={passive:!1},Yk={capture:!0,passive:!1};function Xk(e){e.stopImmediatePropagation()}function Zk(e){e.preventDefault(),e.stopImmediatePropagation()}function Qk(e){var t=e.document.documentElement,n=zk(e).on(`dragstart.drag`,Zk,Yk);`onselectstart`in t?n.on(`selectstart.drag`,Zk,Yk):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function $k(e,t){var n=e.document.documentElement,r=zk(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,Zk,Yk),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var eA=e=>()=>e;function tA(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}tA.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function nA(e){return!e.ctrlKey&&!e.button}function rA(){return this.parentNode}function iA(e,t){return t??{x:e.x,y:e.y}}function aA(){return navigator.maxTouchPoints||`ontouchstart`in this}function oA(){var e=nA,t=rA,n=iA,r=aA,i={},a=Uk(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,Jk).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!u&&e.call(this,n,r)){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(zk(n.view).on(`mousemove.drag`,m,Yk).on(`mouseup.drag`,h,Yk),Qk(n.view),Xk(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(Zk(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){zk(e.view).on(`mousemove.drag mouseup.drag`,null),$k(e.view,l),Zk(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,c;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(Xk(n),c(`start`,n,i[s]))}function _(e){for(var t=e.changedTouches,n=t.length,r=0,a;r<n;++r)(a=i[t[r].identifier])&&(Zk(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(Xk(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=Vk(l||r,t),p,m,h;if((h=n.call(e,new tA(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=Vk(l||a,t),_=o}u.call(r,e,new tA(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:eA(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:eA(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:eA(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:eA(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function sA(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function cA(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function lA(){}var uA=.7,dA=1/uA,fA=`\\s*([+-]?\\d+)\\s*`,pA=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,mA=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,hA=/^#([0-9a-f]{3,8})$/,gA=RegExp(`^rgb\\(${fA},${fA},${fA}\\)$`),_A=RegExp(`^rgb\\(${mA},${mA},${mA}\\)$`),vA=RegExp(`^rgba\\(${fA},${fA},${fA},${pA}\\)$`),yA=RegExp(`^rgba\\(${mA},${mA},${mA},${pA}\\)$`),bA=RegExp(`^hsl\\(${pA},${mA},${mA}\\)$`),xA=RegExp(`^hsla\\(${pA},${mA},${mA},${pA}\\)$`),SA={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};sA(lA,DA,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:CA,formatHex:CA,formatHex8:wA,formatHsl:TA,formatRgb:EA,toString:EA});function CA(){return this.rgb().formatHex()}function wA(){return this.rgb().formatHex8()}function TA(){return BA(this).formatHsl()}function EA(){return this.rgb().formatRgb()}function DA(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=hA.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?OA(t):n===3?new MA(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?kA(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?kA(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=gA.exec(e))?new MA(t[1],t[2],t[3],1):(t=_A.exec(e))?new MA(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=vA.exec(e))?kA(t[1],t[2],t[3],t[4]):(t=yA.exec(e))?kA(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=bA.exec(e))?zA(t[1],t[2]/100,t[3]/100,1):(t=xA.exec(e))?zA(t[1],t[2]/100,t[3]/100,t[4]):SA.hasOwnProperty(e)?OA(SA[e]):e===`transparent`?new MA(NaN,NaN,NaN,0):null}function OA(e){return new MA(e>>16&255,e>>8&255,e&255,1)}function kA(e,t,n,r){return r<=0&&(e=t=n=NaN),new MA(e,t,n,r)}function AA(e){return e instanceof lA||(e=DA(e)),e?(e=e.rgb(),new MA(e.r,e.g,e.b,e.opacity)):new MA}function jA(e,t,n,r){return arguments.length===1?AA(e):new MA(e,t,n,r??1)}function MA(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}sA(MA,jA,cA(lA,{brighter(e){return e=e==null?dA:dA**+e,new MA(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?uA:uA**+e,new MA(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new MA(LA(this.r),LA(this.g),LA(this.b),IA(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:NA,formatHex:NA,formatHex8:PA,formatRgb:FA,toString:FA}));function NA(){return`#${RA(this.r)}${RA(this.g)}${RA(this.b)}`}function PA(){return`#${RA(this.r)}${RA(this.g)}${RA(this.b)}${RA((isNaN(this.opacity)?1:this.opacity)*255)}`}function FA(){let e=IA(this.opacity);return`${e===1?`rgb(`:`rgba(`}${LA(this.r)}, ${LA(this.g)}, ${LA(this.b)}${e===1?`)`:`, ${e})`}`}function IA(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function LA(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function RA(e){return e=LA(e),(e<16?`0`:``)+e.toString(16)}function zA(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new HA(e,t,n,r)}function BA(e){if(e instanceof HA)return new HA(e.h,e.s,e.l,e.opacity);if(e instanceof lA||(e=DA(e)),!e)return new HA;if(e instanceof HA)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new HA(o,s,c,e.opacity)}function VA(e,t,n,r){return arguments.length===1?BA(e):new HA(e,t,n,r??1)}function HA(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}sA(HA,VA,cA(lA,{brighter(e){return e=e==null?dA:dA**+e,new HA(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?uA:uA**+e,new HA(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new MA(GA(e>=240?e-240:e+120,i,r),GA(e,i,r),GA(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new HA(UA(this.h),WA(this.s),WA(this.l),IA(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=IA(this.opacity);return`${e===1?`hsl(`:`hsla(`}${UA(this.h)}, ${WA(this.s)*100}%, ${WA(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function UA(e){return e=(e||0)%360,e<0?e+360:e}function WA(e){return Math.max(0,Math.min(1,e||0))}function GA(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var KA=e=>()=>e;function qA(e,t){return function(n){return e+n*t}}function JA(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function YA(e){return(e=+e)==1?XA:function(t,n){return n-t?JA(t,n,e):KA(isNaN(t)?n:t)}}function XA(e,t){var n=t-e;return n?qA(e,n):KA(isNaN(e)?t:e)}var ZA=(function e(t){var n=YA(t);function r(e,t){var r=n((e=jA(e)).r,(t=jA(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=XA(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function QA(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var $A=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ej=new RegExp($A.source,`g`);function tj(e){return function(){return e}}function nj(e){return function(t){return e(t)+``}}function rj(e,t){var n=$A.lastIndex=ej.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=$A.exec(e))&&(i=ej.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:QA(r,i)})),n=ej.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?nj(c[0].x):tj(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}var ij=180/Math.PI,aj={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function oj(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*ij,skewX:Math.atan(c)*ij,scaleX:o,scaleY:s}}var sj;function cj(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?aj:oj(t.a,t.b,t.c,t.d,t.e,t.f)}function lj(e){return e==null||(sj||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),sj.setAttribute(`transform`,e),!(e=sj.transform.baseVal.consolidate()))?aj:(e=e.matrix,oj(e.a,e.b,e.c,e.d,e.e,e.f))}function uj(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:QA(e,i)},{i:c-2,x:QA(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:QA(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:QA(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:QA(e,n)},{i:s-2,x:QA(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var dj=uj(cj,`px, `,`px)`,`deg)`),fj=uj(lj,`, `,`)`,`)`),pj=1e-12;function mj(e){return((e=Math.exp(e))+1/e)/2}function hj(e){return((e=Math.exp(e))-1/e)/2}function gj(e){return((e=Math.exp(2*e))-1)/(e+1)}var _j=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<pj)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=mj(y),c=s/(n*g)*(i*gj(t*r+y)-hj(y));return[a+c*d,o+c*f,s*i/mj(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),vj=0,yj=0,bj=0,xj=1e3,Sj,Cj,wj=0,Tj=0,Ej=0,Dj=typeof performance==`object`&&performance.now?performance:Date,Oj=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function kj(){return Tj||=(Oj(Aj),Dj.now()+Ej)}function Aj(){Tj=0}function jj(){this._call=this._time=this._next=null}jj.prototype=Mj.prototype={constructor:jj,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?kj():+n)+(t==null?0:+t),!this._next&&Cj!==this&&(Cj?Cj._next=this:Sj=this,Cj=this),this._call=e,this._time=n,Lj()},stop:function(){this._call&&(this._call=null,this._time=1/0,Lj())}};function Mj(e,t,n){var r=new jj;return r.restart(e,t,n),r}function Nj(){kj(),++vj;for(var e=Sj,t;e;)(t=Tj-e._time)>=0&&e._call.call(void 0,t),e=e._next;--vj}function Pj(){Tj=(wj=Dj.now())+Ej,vj=yj=0;try{Nj()}finally{vj=0,Ij(),Tj=0}}function Fj(){var e=Dj.now(),t=e-wj;t>xj&&(Ej-=t,wj=e)}function Ij(){for(var e,t=Sj,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Sj=n);Cj=e,Lj(r)}function Lj(e){vj||(yj&&=clearTimeout(yj),e-Tj>24?(e<1/0&&(yj=setTimeout(Pj,e-Dj.now()-Ej)),bj&&=clearInterval(bj)):(bj||=(wj=Dj.now(),setInterval(Fj,xj)),vj=1,Oj(Pj)))}function Rj(e,t,n){var r=new jj;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var zj=Uk(`start`,`end`,`cancel`,`interrupt`),Bj=[];function Vj(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Gj(e,n,{name:t,index:r,group:i,on:zj,tween:Bj,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function Hj(e,t){var n=Wj(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function Uj(e,t){var n=Wj(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function Wj(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Gj(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Mj(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return Rj(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(Rj(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function Kj(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n)(r=n[o]).name===t?(i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]):a=!1;a&&delete e.__transition}}function qj(e){return this.each(function(){Kj(this,e)})}function Jj(e,t){var n,r;return function(){var i=Uj(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function Yj(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=Uj(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function Xj(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=Wj(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?Jj:Yj)(n,e,t))}function Zj(e,t,n){var r=e._id;return e.each(function(){var e=Uj(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return Wj(e,r).value[t]}}function Qj(e,t){var n;return(typeof t==`number`?QA:t instanceof DA?ZA:(n=DA(t))?(t=n,ZA):rj)(e,t)}function $j(e){return function(){this.removeAttribute(e)}}function eM(e){return function(){this.removeAttributeNS(e.space,e.local)}}function tM(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function nM(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function rM(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function iM(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function aM(e,t){var n=HD(e),r=n===`transform`?fj:Qj;return this.attrTween(e,typeof t==`function`?(n.local?iM:rM)(n,r,Zj(this,`attr.`+e,t)):t==null?(n.local?eM:$j)(n):(n.local?nM:tM)(n,r,t))}function oM(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function sM(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function cM(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&sM(e,i)),n}return i._value=t,i}function lM(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&oM(e,i)),n}return i._value=t,i}function uM(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=HD(e);return this.tween(n,(r.local?cM:lM)(r,t))}function dM(e,t){return function(){Hj(this,e).delay=+t.apply(this,arguments)}}function fM(e,t){return t=+t,function(){Hj(this,e).delay=t}}function pM(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?dM:fM)(t,e)):Wj(this.node(),t).delay}function mM(e,t){return function(){Uj(this,e).duration=+t.apply(this,arguments)}}function hM(e,t){return t=+t,function(){Uj(this,e).duration=t}}function gM(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?mM:hM)(t,e)):Wj(this.node(),t).duration}function _M(e,t){if(typeof t!=`function`)throw Error();return function(){Uj(this,e).ease=t}}function vM(e){var t=this._id;return arguments.length?this.each(_M(t,e)):Wj(this.node(),t).ease}function yM(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();Uj(this,e).ease=n}}function bM(e){if(typeof e!=`function`)throw Error();return this.each(yM(this._id,e))}function xM(e){typeof e!=`function`&&(e=eO(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new XM(r,this._parents,this._name,this._id)}function SM(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new XM(o,this._parents,this._name,this._id)}function CM(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function wM(e,t,n){var r,i,a=CM(t)?Hj:Uj;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function TM(e,t){var n=this._id;return arguments.length<2?Wj(this.node(),n).on.on(e):this.each(wM(n,e,t))}function EM(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function DM(){return this.on(`end.remove`,EM(this._id))}function OM(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=qD(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,Vj(l[f],t,n,f,l,Wj(u,n)));return new XM(a,this._parents,t,n)}function kM(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=ZD(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=Wj(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&Vj(p,t,n,h,f,m);a.push(f),o.push(u)}return new XM(a,o,t,n)}var AM=Lk.prototype.constructor;function jM(){return new AM(this._groups,this._parents)}function MM(e,t){var n,r,i;return function(){var a=WO(this,e),o=(this.style.removeProperty(e),WO(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function NM(e){return function(){this.style.removeProperty(e)}}function PM(e,t,n){var r,i=n+``,a;return function(){var o=WO(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function FM(e,t,n){var r,i,a;return function(){var o=WO(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),WO(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function IM(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=Uj(this,e),l=c.on,u=c.value[a]==null?s||=NM(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function LM(e,t,n){var r=(e+=``)==`transform`?dj:Qj;return t==null?this.styleTween(e,MM(e,r)).on(`end.style.`+e,NM(e)):typeof t==`function`?this.styleTween(e,FM(e,r,Zj(this,`style.`+e,t))).each(IM(this._id,e)):this.styleTween(e,PM(e,r,t),n).on(`end.style.`+e,null)}function RM(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function zM(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&RM(e,a,n)),r}return a._value=t,a}function BM(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,zM(e,t,n??``))}function VM(e){return function(){this.textContent=e}}function HM(e){return function(){var t=e(this);this.textContent=t??``}}function UM(e){return this.tween(`text`,typeof e==`function`?HM(Zj(this,`text`,e)):VM(e==null?``:e+``))}function WM(e){return function(t){this.textContent=e.call(this,t)}}function GM(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&WM(r)),t}return r._value=e,r}function KM(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,GM(e))}function qM(){for(var e=this._name,t=this._id,n=ZM(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=Wj(c,t);Vj(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new XM(r,this._parents,e,n)}function JM(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=Uj(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var YM=0;function XM(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function ZM(){return++YM}var QM=Lk.prototype;XM.prototype={constructor:XM,select:OM,selectAll:kM,selectChild:QM.selectChild,selectChildren:QM.selectChildren,filter:xM,merge:SM,selection:jM,transition:qM,call:QM.call,nodes:QM.nodes,node:QM.node,size:QM.size,empty:QM.empty,each:QM.each,on:TM,attr:aM,attrTween:uM,style:LM,styleTween:BM,text:UM,textTween:KM,remove:DM,tween:Xj,delay:pM,duration:gM,ease:vM,easeVarying:bM,end:JM,[Symbol.iterator]:QM[Symbol.iterator]};function $M(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var eN={time:null,delay:0,duration:250,ease:$M};function tN(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function nN(e){var t,n;e instanceof XM?(t=e._id,e=e._name):(t=ZM(),(n=eN).time=kj(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&Vj(c,e,t,l,o,n||tN(c,t));return new XM(r,this._parents,e,t)}Lk.prototype.interrupt=qj,Lk.prototype.transition=nN;var rN=e=>()=>e;function iN(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function aN(e,t,n){this.k=e,this.x=t,this.y=n}aN.prototype={constructor:aN,scale:function(e){return e===1?this:new aN(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new aN(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var oN=new aN(1,0,0);sN.prototype=aN.prototype;function sN(e){for(;!e.__zoom;)if(!(e=e.parentNode))return oN;return e.__zoom}function cN(e){e.stopImmediatePropagation()}function lN(e){e.preventDefault(),e.stopImmediatePropagation()}function uN(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function dN(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function fN(){return this.__zoom||oN}function pN(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function mN(){return navigator.maxTouchPoints||`ontouchstart`in this}function hN(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function gN(){var e=uN,t=dN,n=hN,r=pN,i=mN,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=_j,l=Uk(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,fN).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,fN),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(oN.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new aN(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new aN(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new aN(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=zk(this.that).datum();l.call(e,this.that,new iN(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=Vk(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],Kj(this),s.start();lN(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=zk(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=Vk(t,i),l=t.clientX,u=t.clientY;Qk(t.view),cN(t),a.mouse=[c,this.__zoom.invert(c)],Kj(this),a.start();function d(e){if(lN(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=Vk(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),$k(e.view,a.moved),lN(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=Vk(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);lN(r),s>0?zk(this).transition().duration(s).call(x,d,c,r):zk(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(cN(t),s=0;s<i;++s)c=r[s],l=Vk(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),Kj(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(lN(e),s=0;s<a;++s)c=i[s],l=Vk(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(cN(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=Vk(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=zk(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:rN(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:rN(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:rN(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:rN([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var _N=`/api/live`,vN=`frameboard.seen`;function yN(e){let t=ue()(()=>({unseen:{},seen:DN(e),cursor:null}));return Object.assign(t,{storage:e})}function bN(e,t){let{unseen:n,seen:r}=e.getState(),i={...n};for(let e of t)r[e.frame]===e.hash?delete i[e.frame]:i[e.frame]=e;e.setState({unseen:i})}function xN(e,t){let{unseen:n,seen:r}=e.getState(),i=n[t];if(!i)return;let{[t]:a,...o}=n,s={...r,[t]:i.hash};e.setState({unseen:o,seen:s}),ON(e.storage,s)}function SN(e,t){let n=new Set(t.projects.flatMap(e=>e.pages.flatMap(e=>e.frames.map(e=>e.ref)))),{unseen:r}=e.getState(),i=Object.fromEntries(Object.entries(r).filter(([e])=>n.has(e)));Object.keys(i).length!==Object.keys(r).length&&e.setState({unseen:i})}function CN(e,t){e.setState({cursor:t})}function wN(e,t){let n=`${t}/`;return Object.keys(e).filter(e=>e.startsWith(n)).length}function TN(e){return Object.values(e).sort((e,t)=>e.at.localeCompare(t.at)||e.id.localeCompare(t.id))}function EN(e,t){let n=TN(e);return n[(n.findIndex(e=>e.frame===t)+1)%n.length]??null}function DN(e){try{let t=JSON.parse(e?.getItem(`frameboard.seen`)??`{}`);return typeof t!=`object`||!t?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]==`string`))}catch{return{}}}function ON(e,t){try{e?.setItem(vN,JSON.stringify(t))}catch{}}function kN(){try{return window.localStorage}catch{return null}}var AN=yN(kN());function jN(e){return fe(AN,e)}var MN=crypto.randomUUID(),NN=500;function PN(e,{onShow:t,unseen:n=AN}={}){let r,i,a=!1,o=()=>{let s=location.protocol===`https:`?`wss`:`ws`;r=new WebSocket(`${s}://${location.host}${_N}`),r.addEventListener(`open`,()=>{let t={type:`hello`,role:`board`,tab:MN};r?.send(JSON.stringify(t)),e.setState({connected:!0})}),r.addEventListener(`message`,r=>{let i=JSON.parse(String(r.data));if(i.type===`board`)ll(e,i.data),SN(n,i.data);else if(i.type===`changes`){bN(n,i.changes);let{board:t}=e.getState();t&&SN(n,t)}else i.type===`access`?_l(e,i.write):i.type===`reload`?vl(e,i.refs):i.type===`findings`?gl(e,i.findings):i.type===`notes`?ul(e,i.page,i.notes):i.type===`listeners`?dl(e,i.listeners):i.type===`history`?fl(e,{undo:i.undo,redo:i.redo}):i.type===`claims`?pl(e,i.claims):i.type===`thumbnails`?ml(e,i.theme,i.stamps):i.type===`show`&&t?.(i.ref)}),r.addEventListener(`close`,()=>{hl(e),a||(i=setTimeout(o,NN))})};return o(),()=>{a=!0,clearTimeout(i),r?.close()}}var FN=1500;function IN(e,{store:t=AN,doc:n=document}={}){let r=(0,y.useRef)(e),i=(0,y.useRef)(()=>{});(0,y.useEffect)(()=>{let e=new Map,a=t=>{clearTimeout(e.get(t)),e.delete(t)},o=()=>{let i=r.current,{unseen:o}=t.getState(),s=i&&n.visibilityState===`visible`?new Set(i.frames.filter(e=>e.ref in o).filter(e=>LN(e.box,i.view,i.size)).map(e=>e.ref)):new Set;for(let t of[...e.keys()])s.has(t)||a(t);for(let n of s)e.has(n)||e.set(n,setTimeout(()=>{e.delete(n),xN(t,n)},FN))},s=()=>{for(let e of bD.getState().frames)xN(t,e)};i.current=o,o(),s();let c=t.subscribe((e,t)=>{e.unseen!==t.unseen&&(s(),o())}),l=bD.subscribe(s);return n.addEventListener(`visibilitychange`,o),()=>{c(),l(),n.removeEventListener(`visibilitychange`,o);for(let t of[...e.keys()])a(t);i.current=()=>{}}},[t,n]),(0,y.useEffect)(()=>{r.current=e,i.current()},[e])}function LN(e,t,n){let r=Math.max(e.x*t.k+t.x,0),i=Math.max(e.y*t.k+t.y,0),a=Math.min((e.x+e.width)*t.k+t.x,n.width),o=Math.min((e.y+e.height)*t.k+t.y,n.height),s=Math.max(0,a-r)*Math.max(0,o-i),c=e.width*t.k*e.height*t.k;return c>0&&s*2>=c}function RN(e){return[...e.querySelectorAll(`*`)].filter(e=>!e.hasAttribute(V_))}function zN(e,t){let n=RN(e).indexOf(t);return n===-1?null:n}function BN(e,t){return RN(e)[t]??null}function VN(e){return e.querySelector(`style[data-frameboard]`)?.getAttribute(`data-hash`)??null}var HN=e=>`calc(${e}px / var(--zoom, 1))`,UN=`${HN(1.5)} solid var(--primary)`;function WN(e){return`${e.width} × ${e.height}`}function GN(e,t){return{left:e.x-(t?.x??0),top:e.y-(t?.y??0),width:e.width,height:e.height}}function KN(e,t,n,r){let i=eP(e,`[data-selection]`);if(!i)return;i.style.transform=`translate(${t}px, ${n}px)`,tP(i,`[data-handles]`,!0),tP(i,`[data-chip]`,!0);let a=eP(i,`[data-move-chip]`);a&&(a.hidden=!1,a.textContent=`${r.x}, ${r.y}`)}function qN(e,t){let n=eP(e,`[data-selection]`),r=DE(Object.values(t));if(!n||!r)return;Object.assign(n.style,$N(GN(r)));for(let[e,i]of Object.entries(t)){let t=eP(n,`[data-outline="${CSS.escape(e)}"]`);t&&Object.assign(t.style,$N(GN(i,r)))}let i=eP(n,`[data-chip]`);i&&Object.keys(t).length===1&&(i.textContent=WN(r))}function JN(e,t,n){let r=eP(e,`[data-marquee]`);r&&(r.hidden=t===null,t&&Object.assign(r.style,$N(GN(t)))),eP(e,`[data-marquee-hits]`)?.replaceChildren(...n.map(e=>{let t=document.createElement(`div`);return t.className=`absolute`,Object.assign(t.style,$N(GN(e)),{outline:UN}),t}))}function YN(e,t,n){eP(e,`[data-guides]`)?.replaceChildren(...t.map(e=>ZN(e.axis===`x`?`vertical`:`horizontal`,e)),...n.flatMap(e=>[ZN(e.axis===`x`?`horizontal`:`vertical`,e),QN(e)]))}function XN(e){let t=eP(e,`[data-selection]`);if(t){let e=t.hasAttribute(`data-inside`);t.style.transform=``,tP(t,`[data-handles]`,e),tP(t,`[data-chip]`,e),tP(t,`[data-move-chip]`,!0)}JN(e,null,[]),YN(e,[],[])}function ZN(e,{at:t,from:n,to:r}){let i=document.createElement(`div`);return i.className=`absolute bg-guide`,i.dataset.guide=e,Object.assign(i.style,e===`vertical`?{left:`${t}px`,top:`${n}px`,height:`${r-n}px`,width:HN(1)}:{top:`${t}px`,left:`${n}px`,width:`${r-n}px`,height:HN(1)}),i}function QN(e){let t=document.createElement(`span`),n=Math.round(e.to-e.from);t.dataset.gap=String(n),t.textContent=String(n),t.className=`absolute origin-top-left rounded-[4px] bg-guide px-[5px] py-px text-[10px] leading-[14px] text-white tabular-nums`;let r=(e.from+e.to)/2;return Object.assign(t.style,{left:`${e.axis===`x`?r:e.at}px`,top:`${e.axis===`x`?e.at:r}px`,transform:`scale(calc(1 / var(--zoom, 1))) translate(-50%, -120%)`}),t}function $N(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,`${t}px`]))}function eP(e,t){return e.querySelector(t)}function tP(e,t,n){let r=eP(e,t);r&&(r.hidden=n)}var nP=[`nw`,`ne`,`sw`,`se`],rP=`${HN(1)} dashed var(--primary)`,iP=1e6,aP=`absolute top-full left-1/2 origin-top-left rounded-[4px] bg-primary px-1.5 py-0.5 text-[10px] leading-[14px] whitespace-nowrap text-primary-foreground tabular-nums [transform:scale(calc(1/var(--zoom,1)))_translate(-50%,6px)]`;function oP({frames:e}){let t=xD(e=>e.frames),n=xD(e=>!!e.element),r=jE(e.filter(e=>t.includes(e.ref))),i=DE(r.map(e=>e.box));return(0,G.jsxs)(`div`,{"data-overlay":!0,className:`pointer-events-none absolute top-0 left-0`,style:{zIndex:iP},children:[i?(0,G.jsx)(sP,{frames:r,bounds:i,inside:n}):null,(0,G.jsx)(`div`,{"data-marquee-hits":!0}),(0,G.jsx)(`div`,{"data-marquee":!0,hidden:!0,className:`absolute bg-primary/10`,style:{border:`${HN(1)} solid var(--primary)`}}),(0,G.jsx)(`div`,{"data-guides":!0})]})}function sP({frames:e,bounds:t,inside:n}){let r=e.length>1;return(0,G.jsxs)(`div`,{"data-selection":!0,"data-inside":n||void 0,className:`absolute`,style:{...GN(t),...n?{outline:rP,outlineOffset:HN(1)}:{outline:UN}},children:[r?e.map(e=>(0,G.jsx)(`div`,{"data-outline":e.ref,className:`absolute`,style:{...GN(e.box,t),outline:UN}},e.ref)):null,(0,G.jsx)(`div`,{"data-handles":!0,hidden:n,children:nP.map(e=>(0,G.jsx)(`span`,{"data-handle":e,className:`absolute -translate-1/2 border-primary bg-white`,style:{left:e.endsWith(`w`)?0:`100%`,top:e.startsWith(`n`)?0:`100%`,width:HN(7),height:HN(7),borderWidth:HN(1.5)}},e))}),(0,G.jsx)(`span`,{"data-chip":!0,hidden:n,className:aP,children:r?`${e.length} frames`:WN(t)}),(0,G.jsx)(`span`,{"data-move-chip":!0,hidden:!0,className:aP})]})}var cP=ue()(()=>({glowing:{},replays:{}})),lP=new Set;function uP(e){cP.setState(t=>({replays:{...t.replays,[e]:!0}}))}var dP=2e3,fP=1;function pP({frames:e,container:t}){let n=aD(e=>e.mode===`play`),[r,i]=(0,y.useState)({}),a=(0,y.useRef)(e);if((0,y.useLayoutEffect)(()=>{a.current=e},[e]),(0,y.useEffect)(()=>{if(!t||n)return;let e=new Set,r=(t,n,r)=>{let a=fP++,o=n.whole?[{x:0,y:0,width:t.box.width,height:t.box.height}]:n.elements.flatMap(e=>{let t=BN(r,e);if(!t)return[];let n=t.getBoundingClientRect();return[{x:n.left,y:n.top,width:n.width,height:n.height}]});if(lP.add(n.id),o.length===0)return;i(e=>({...e,[t.ref]:{key:a,boxes:o}})),cP.setState(e=>({glowing:{...e.glowing,[t.ref]:a}}));let s=setTimeout(()=>{e.delete(s),i(e=>{if(e[t.ref]?.key!==a)return e;let{[t.ref]:n,...r}=e;return r}),cP.setState(e=>{if(e.glowing[t.ref]!==a)return e;let{[t.ref]:n,...r}=e.glowing;return{glowing:r}})},dP);e.add(s)},o=()=>{let{unseen:e}=AN.getState(),{replays:n}=cP.getState(),i=[];for(let o of a.current){let a=e[o.ref];if(!a)continue;let s=o.ref in n;if(lP.has(a.id)&&!s)continue;let c=t.querySelector(`[data-frame="${CSS.escape(o.ref)}"] iframe`)?.contentDocument;c&&VN(c)===a.hash&&(s&&i.push(o.ref),r(o,a,c))}i.length>0&&cP.setState(e=>({replays:Object.fromEntries(Object.entries(e.replays).filter(([e])=>!i.includes(e)))}))};o(),t.addEventListener(`load`,o,!0);let s=AN.subscribe((e,t)=>{e.unseen!==t.unseen&&o()}),c=cP.subscribe((e,t)=>{e.replays!==t.replays&&o()});return()=>{t.removeEventListener(`load`,o,!0),s(),c();for(let t of e)clearTimeout(t);i({}),cP.setState({glowing:{}})}},[t,n]),n)return null;let o=new Map(e.map(e=>[e.ref,e]));return Object.entries(r).flatMap(([e,{key:t,boxes:n}])=>{let r=o.get(e);return r?n.map((n,i)=>(0,G.jsx)(`span`,{"data-change-glow":e,"aria-hidden":!0,className:`pointer-events-none absolute rounded-[calc(8px/var(--zoom,1))] bg-[color-mix(in_srgb,var(--claim)_12%,transparent)] motion-safe:animate-change-glow`,style:{left:`calc(${r.box.x+n.x}px - ${HN(4)})`,top:`calc(${r.box.y+n.y}px - ${HN(4)})`,width:`calc(${n.width}px + ${HN(8)})`,height:`calc(${n.height}px + ${HN(8)})`,boxShadow:`0 0 0 ${HN(2)} var(--claim), 0 0 ${HN(18)} color-mix(in srgb, var(--claim) 55%, transparent)`,zIndex:iP-1}},`${t}-${i}`)):[]})}function mP(e){return e.slice(0,1).toUpperCase()}var hP=`claude`;function gP(e){let[t,n]=e.split(` · `);return n===void 0||!t?hP:t}function _P(e,t){let n=Math.max(0,Math.floor((t-Date.parse(e))/1e3));return n<60?`${n}s`:`${Math.floor(n/60)}m`}function vP(){let[e,t]=(0,y.useState)(()=>Date.now());return(0,y.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}var yP=`pointer-events-none w-[280px] rounded-[10px] border border-[color-mix(in_srgb,var(--claim)_50%,var(--border))] bg-card px-3 py-2.5 text-xs leading-[1.45] text-card-foreground shadow-[0_10px_30px_rgba(0,0,0,0.3)]`;function bP({page:e,frames:t}){let n=vE(),r=aD(e=>e.mode===`play`);(0,y.useEffect)(()=>{r&&SE()},[r]),(0,y.useEffect)(()=>()=>SE(),[e]);let i=n.length>0;(0,y.useEffect)(()=>{if(!i)return;let e=e=>{e.key===`Escape`&&SE()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let a=jE(t);if(r)return null;let o=SP(n);return a.flatMap(e=>{let t=o.get(e.ref);return t?(0,G.jsx)(`div`,{className:`absolute origin-top-left [transform:scale(calc(1/var(--zoom,1)))]`,style:{left:`calc(${e.box.x}px + ${HN(72)})`,top:`calc(${e.box.y+e.box.height}px - ${HN(38)})`,zIndex:iP+1},children:(0,G.jsx)(CP,{frame:e.name,...t})},e.ref):[]})}function xP({frames:e}){let t=vE();if(aD(e=>e.mode===`play`))return null;let n=new Set(e.map(e=>e.ref)),r=[...SP(t)].filter(([e])=>!n.has(e));return r.length===0?null:(0,G.jsx)(`div`,{"data-waiting-dock":!0,className:`absolute bottom-[4.25rem] left-4 flex flex-col gap-2`,style:{zIndex:iP+1},children:r.map(([e,t])=>(0,G.jsx)(CP,{frame:e.slice(e.lastIndexOf(`/`)+1),...t},e))})}function SP(e){let t=new Map;for(let n of e)for(let e of n.holders)t.set(e.frame,{label:n.label,holder:e});return t}function CP({frame:e,label:t,holder:n}){let r=vP(),i=`${mP(n.tag)}${n.tag.slice(1)}`;return(0,G.jsxs)(`div`,{"data-waiting-card":n.frame,role:`status`,className:yP,children:[(0,G.jsxs)(`b`,{className:`block font-semibold`,children:[i,` is editing `,e]}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Your `,t,` will wait until it finishes, about`,` `,(0,G.jsx)(`span`,{"data-waiting-elapsed":!0,children:_P(n.claimedAt,r)}),` so far.`]})]})}function wP(e,t,n){let r=n.width/t.k,i=n.height/t.k,a=-t.x/t.k-r,o=-t.y/t.k-i,s=a+3*r,c=o+3*i,l=new Set;for(let{ref:t,box:n}of e)n.x<s&&n.x+n.width>a&&n.y<c&&n.y+n.height>o&&l.add(t);return l}var TP=ue()(()=>({open:null}));function EP(e){return fe(TP,e)}function DP(){TP.setState({open:null})}var OP=()=>yl.getState().canWrite;function kP(){(0,y.useEffect)(()=>{let e=be([{id:`tool.note`,label:`Note`,group:`tool`,command:{label:`Add a note`,icon:mn},keys:[`n`],enabled:OP,run:()=>iD.setState({tool:`note`,mode:`edit`}),checked:()=>iD.getState().mode===`edit`&&iD.getState().tool===`note`}]),t=yl.subscribe((e,t)=>{e.canWrite!==t.canWrite&&(xe(),!e.canWrite&&iD.getState().tool===`note`&&iD.setState({tool:`move`}),!e.canWrite&&TP.getState().open?.kind===`new`&&DP())}),n=iD.subscribe(e=>{let t=TP.getState().open;(e.mode===`play`||t?.kind===`new`&&e.tool!==`note`)&&DP()});return()=>{n(),t(),e()}},[])}function AP(e){let t=ue()(()=>({byRef:{}})),n=(e,n,r)=>{let i=t.getState().byRef[e];i&&i.version>r||t.setState(t=>({byRef:{...t.byRef,[e]:{...n,version:r}}}))},r=(r,i)=>{let a=t.getState().byRef[r];a&&a.version>=i||(n(r,{status:`loading`},i),e(r).then(e=>n(r,{status:`ready`,tree:e},i),e=>n(r,{status:`refused`,message:e instanceof Error?e.message:String(e)},i)))};return{store:t,request:r,read:(e,n)=>(r(e,n),new Promise(n=>{let r=()=>{let r=t.getState().byRef[e];return!r||r.status===`loading`?!1:(n(r.status===`ready`?r.tree:null),!0)};if(r())return;let i=t.subscribe(()=>{r()&&i()})}))}}async function jP(e,t=fetch){let n=await t(`/api/frames/elements?ref=${encodeURIComponent(e)}`),r=await n.json().catch(()=>null);if(!r)throw Error(`The board answered ${n.status}.`);if(!r.ok)throw Error(r.error.message);return r.data}var MP=AP(e=>jP(e));function NP(e){let t=MP.store.getState().byRef[e];return t?.status===`ready`?t.tree:null}function PP(e){let t=Z(t=>e?t.reloads[e]??0:0);return(0,y.useEffect)(()=>{e&&MP.request(e,t)},[e,t]),fe(MP.store,t=>e?t.byRef[e]??null:null)}function FP(e){MP.request(e,yl.getState().reloads[e]??0)}function IP(e){return MP.read(e,yl.getState().reloads[e]??0)}function LP(e,t){return e.find(e=>e.parent===t)?.index}function RP(e,t){return e.find(e=>e.index===t)?.parent}function zP(e,t,n){let r=RP(e,t);if(r===void 0)return;let i=e.filter(e=>e.parent===r),a=i.findIndex(e=>e.index===t),o=i.length;return i[(a+n+o)%o]?.index}function BP(){let e=document.activeElement;return!e||e===document.body||e.closest(`[data-canvas]`)!==null}function VP(e){let{selection:t,mode:n}=e,r=()=>{let{page:r,frames:i,element:a}=t.getState(),o=i[0];if(n.getState().mode!==`edit`||r!==e.page()||i.length!==1||!o)return null;let s=e.treeOf(o);return!s||a&&a.hash!==s.hash?null:{page:r,frame:o,at:a?.index??null,tree:s}},i=e=>{let n=()=>{let t=r();if(!t)return;let n=e(t.tree.elements,t.at);return n===void 0?void 0:{...t,next:n}};return{enabled:()=>n()!==void 0,run:()=>{let e=n();if(!e)return;let{page:r,frame:i,next:a,tree:o}=e;if(a===null)sD(t,r,[i]);else{let e={frame:i,index:a,hash:o.hash};cD(t,r,e)}}}},a=e=>(t,n)=>n===null?void 0:e(t,n),o=t=>({enabled:()=>e.boardFocused()&&t.enabled(),run:t.run}),s=i(a(RP)),c=()=>{let{page:r,element:i}=t.getState();return n.getState().mode===`edit`&&r===e.page()&&!!i};return[{id:`element.down`,label:`Select child`,group:`selection`,keys:[`Enter`],...o(i(LP))},{id:`element.up`,label:`Select parent`,group:`selection`,keys:[`Escape`],enabled:()=>c()&&(e.noteOpen()||s.enabled()),run:()=>{e.noteOpen()||s.run()}},{id:`element.next`,label:`Select next sibling`,group:`selection`,keys:[`Tab`],...o(i(a((e,t)=>zP(e,t,1))))},{id:`element.previous`,label:`Select previous sibling`,group:`selection`,keys:[`Shift+Tab`],...o(i(a((e,t)=>zP(e,t,-1))))}]}function HP(e){(0,y.useEffect)(()=>{let t=be(VP({page:()=>e,selection:bD,mode:iD,treeOf:NP,noteOpen:()=>TP.getState().open!==null,boardFocused:BP})),n=()=>{let{frames:e}=bD.getState();e.length===1&&e[0]&&FP(e[0])};n();let r=[bD.subscribe(n),yl.subscribe((e,t)=>{e.reloads!==t.reloads&&n()}),bD.subscribe(xe),iD.subscribe(xe),TP.subscribe(xe),MP.store.subscribe(xe)];return()=>{for(let e of r)e();t()}},[e])}var UP=[{left:0,top:0},{left:`100%`,top:0},{left:0,top:`100%`},{left:`100%`,top:`100%`}];function WP({frames:e,container:t}){let n=xD(e=>e.element??null),r=e.find(e=>e.ref===n?.frame),i=AE(r?.ref??``),a=GP(t,n),o=i??r?.box;return!o||!a?null:(0,G.jsxs)(`div`,{"data-element-selection":!0,className:`pointer-events-none absolute`,style:{left:o.x+a.x,top:o.y+a.y,width:a.width,height:a.height,outline:UN,outlineOffset:HN(2),zIndex:iP},children:[UP.map(e=>(0,G.jsx)(`span`,{"data-element-corner":!0,className:`absolute -translate-1/2 border-primary bg-white`,style:{...e,width:HN(7),height:HN(7),borderWidth:HN(1.5)}},`${e.left}-${e.top}`)),(0,G.jsx)(`span`,{"data-chip":!0,className:aP,children:WN(a)})]})}function GP(e,t){let[n,r]=(0,y.useState)(null),i=t?.frame,a=t?.index,o=t?.hash,s=t?`${i}:${a}:${o}`:null;return(0,y.useEffect)(()=>{if(!e||s===null||i===void 0||a===void 0)return;let t=e=>r({key:s,box:e}),n=()=>{},c=()=>{n();let r=e.querySelector(`[data-frame="${CSS.escape(i)}"] iframe`)?.contentDocument,s=r&&VN(r)===o?BN(r,a):null,c=r?.defaultView;if(!s||!c){t(null);return}let l=()=>{let e=s.getBoundingClientRect();t({x:Math.round(e.left),y:Math.round(e.top),width:Math.round(e.width),height:Math.round(e.height)})};l();let u=new c.ResizeObserver(l);u.observe(s),u.observe(s.ownerDocument.documentElement),c.addEventListener(`scroll`,l,!0),n=()=>{u.disconnect(),c.removeEventListener(`scroll`,l,!0)}};return c(),e.addEventListener(`load`,c,!0),()=>{e.removeEventListener(`load`,c,!0),n()}},[e,s,i,a,o]),n?.key===s?n.box:null}var KP=new Set([`HTML`,`BODY`]);function qP(e,t,n){let r=[...t].filter(e=>!e.hidden&&JP(e.box,n)).sort((e,t)=>t.order-e.order)[0];if(!r)return null;let i=e.querySelector(`[data-frame="${CSS.escape(r.ref)}"] iframe`),a=i?.contentDocument,o=a?.elementFromPoint(n.x-r.box.x,n.y-r.box.y),s=i?.dataset.renderedAt??null,c=a&&o&&s&&!KP.has(o.tagName)?zN(a,o):null;return{frame:{ref:r.ref,name:r.name},element:c,renderedAt:c===null?null:s,at:n}}function JP(e,{x:t,y:n}){return t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height}function YP(e,t,n,r){let i=qP(e,t,n);if(!i||i.element===null)return null;let a=e.querySelector(`[data-frame="${CSS.escape(i.frame.ref)}"] iframe`)?.contentDocument,o=a?VN(a):null;if(!a||!o)return null;let s=r(i.frame.ref);if(s?.hash!==o)return null;for(let e=BN(a,i.element);e&&e!==a.body;e=e.parentElement){let t=zN(a,e);if(t!==null&&s.elements.find(e=>e.index===t)?.tag===e.localName)return{frame:i.frame.ref,index:t,hash:o}}return null}async function XP(e,t,n,r){let i=qP(e,t,n);if(!i||i.element===null)return null;let a=await r(i.frame.ref);return a?YP(e,t,n,()=>a):null}function ZP(e,t,n,r){let i=0,a=0,o=!1,s=()=>{!o&&a!==i&&t.getState().canWrite&&(o=!0,a=i,r({tab:n,...QP(e.getState())}).catch(()=>{}).finally(()=>{o=!1,s()}))},c=()=>{i+=1,s()};c();let l=e.subscribe(c),u=t.subscribe((e,t)=>{e.canWrite&&!t.canWrite&&c()});return()=>{u(),l()}}function QP({page:e,frames:t,element:n}){return{page:e,frames:[...t],element:n?{ref:n.frame,index:n.index,hash:n.hash}:null}}function $P(){return(0,G.jsx)(`span`,{role:`img`,"aria-label":`Unseen change`,"data-unseen":!0,className:`inline-block size-[7px] shrink-0 rounded-full bg-claim`})}function eF({claim:e}){let t=vP(),n=`${mP(e.tag)}${e.tag.slice(1)}`;return(0,G.jsxs)(`span`,{"data-claim-tag":!0,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full bg-[color-mix(in_srgb,var(--claim)_18%,transparent)] py-0.5 pr-2 pl-[3px] font-medium text-claim motion-safe:animate-claim-tag`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`grid size-4 place-items-center rounded-full bg-claim text-[9px] font-bold text-card`,children:mP(e.agent)}),n,(0,G.jsxs)(`span`,{"data-claim-elapsed":!0,className:`font-normal text-muted-foreground`,children:[`editing · `,_P(e.claimedAt,t)]})]})}var tF=[`Escape`],nF=(0,y.memo)(function({frame:e,live:t,version:n,findings:r,claim:i,unseen:a=!1}){let{x:o,y:s,width:c,height:l}=AE(e.ref)??e.box,u=xD(t=>t.frames.includes(e.ref)),d=(0,y.useRef)(null),f=aD(e=>e.mode===`play`),p=nv(e.ref),m=(0,y.useRef)(e.modifiedAt);(0,y.useEffect)(()=>{m.current=e.modifiedAt},[e.modifiedAt]);let h=(0,y.useMemo)(()=>t?G_(e.ref,ev(e.ref),n):null,[e.ref,n,t]);(0,y.useEffect)(()=>{let e=d.current;if(!t||!e)return;let n=()=>{let t=e.contentDocument?.documentElement;t&&U_(t,p)};return n(),e.addEventListener(`load`,n),()=>e.removeEventListener(`load`,n)},[p,t]),(0,y.useEffect)(()=>{let e=d.current;if(!t||!e)return;let n=()=>{e.dataset.renderedAt=m.current};return e.addEventListener(`load`,n),()=>e.removeEventListener(`load`,n)},[t]),(0,y.useEffect)(()=>{let n=d.current;if(!t||!n)return;let r=()=>{let{page:t,element:r}=bD.getState(),i=n.contentDocument;if(r?.frame!==e.ref||!t||!i)return;let a=VN(i);a===r.hash||_D(e.ref,a)||sD(bD,t,[e.ref])};return n.addEventListener(`load`,r),()=>n.removeEventListener(`load`,r)},[t,e.ref]),(0,y.useEffect)(()=>{let e=d.current;if(!f||!e)return;let t=()=>{},n=()=>{t();let n=e.contentWindow;t=n?De(n,tF):()=>{}};return n(),e.addEventListener(`load`,n),()=>{e.removeEventListener(`load`,n),t()}},[f,t]);let g=i&&!f?i:void 0;return(0,G.jsxs)(`div`,{"data-frame":e.ref,"data-selected":u||void 0,"data-claimed":g?!0:void 0,className:`absolute`,style:{left:o,top:s,width:c,height:l,zIndex:e.order},children:[(0,G.jsxs)(`div`,{className:X(`absolute bottom-full left-0 flex origin-bottom-left items-center gap-1.5 pb-1 text-label [transform:scale(calc(1/var(--zoom,1)))]`,g?`text-claim`:`text-muted-foreground`),style:{maxWidth:`calc(${c}px * var(--zoom, 1))`},title:e.name,children:[e.locked?(0,G.jsx)(un,{role:`img`,"aria-label":`Locked`,className:`size-[11px] shrink-0`,strokeWidth:1.6}):null,a&&!i?(0,G.jsx)($P,{}):null,(0,G.jsx)(`span`,{className:`truncate`,children:e.name}),g?(0,G.jsx)(eF,{claim:g}):null,r&&r.length>0?(0,G.jsx)(iF,{findings:r}):null]}),t?(0,G.jsx)(`iframe`,{ref:d,title:e.name,src:h??void 0,style:{colorScheme:p},className:`block size-full border-0 bg-[color:Canvas]`}):(0,G.jsx)(`div`,{"data-placeholder":!0,className:`size-full border border-border bg-card`}),g?(0,G.jsx)(rF,{}):null]})});function rF(){return(0,G.jsx)(`svg`,{"aria-hidden":!0,"data-claim-outline":!0,className:`pointer-events-none absolute -inset-[calc(3px/var(--zoom,1))] size-[calc(100%+6px/var(--zoom,1))] overflow-visible`,children:(0,G.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`none`,className:`stroke-claim [stroke-width:calc(1.5px/var(--zoom,1))] [stroke-dasharray:calc(4.5px/var(--zoom,1))_calc(3px/var(--zoom,1))] motion-safe:animate-claim-outline`})})}function iF({findings:e}){let t=e.length,n=e.some(e=>e.severity===`error`)?`error`:`warning`;return(0,G.jsxs)(`span`,{role:`img`,"aria-label":`${t} check finding${t===1?``:`s`}`,title:e.map(e=>e.message).join(`
64
- `),"data-severity":n,className:`flex h-[18px] shrink-0 items-center gap-[3px] rounded-[9px] bg-[color-mix(in_srgb,var(--h)_34%,transparent)] pr-1.5 pl-[5px] font-medium text-[color-mix(in_srgb,var(--h)_55%,var(--foreground))] shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--h)_75%,transparent)] data-[severity=error]:[--h:var(--destructive)] data-[severity=warning]:[--h:var(--note)]`,children:[(0,G.jsx)(fr,{"aria-hidden":!0,className:`size-3 text-[var(--h)]`}),t]})}function aF(e,t){let n=Object.entries(e),r=DE(n.map(([,e])=>e));if(!r||n.length<2)return{...e};let i=e=>{switch(t){case`left`:return{...e,x:r.x};case`center`:return{...e,x:Math.round(r.x+(r.width-e.width)/2)};case`right`:return{...e,x:r.x+r.width-e.width};case`top`:return{...e,y:r.y};case`middle`:return{...e,y:Math.round(r.y+(r.height-e.height)/2)};case`bottom`:return{...e,y:r.y+r.height-e.height}}};return Object.fromEntries(n.map(([e,t])=>[e,i(t)]))}function oF(e,t){let n=Object.entries(e);if(n.length<3)return{...e};let r=e=>t===`horizontal`?e.x:e.y,i=e=>t===`horizontal`?e.width:e.height,a=n.toSorted(([,e],[,t])=>r(e)-r(t)||i(e)-i(t)),[,o]=a[0]??[],[,s]=a.at(-1)??[];if(!o||!s)return{...e};let c=(r(s)+i(s)-r(o)-a.reduce((e,[,t])=>e+i(t),0))/(a.length-1),l={},u=r(o);for(let[e,n]of a){let r=Math.round(u);l[e]=t===`horizontal`?{...n,x:r}:{...n,y:r},u+=i(n)+c}return l}var sF=[{name:`Left`,key:`ArrowLeft`,dx:-1,dy:0},{name:`Right`,key:`ArrowRight`,dx:1,dy:0},{name:`Up`,key:`ArrowUp`,dx:0,dy:-1},{name:`Down`,key:`ArrowDown`,dx:0,dy:1}],cF=[{id:`arrange.alignLeft`,label:`Align left`,alignment:`left`,key:`Alt+KeyA`},{id:`arrange.alignCenter`,label:`Align horizontal centers`,alignment:`center`,key:`Alt+KeyH`},{id:`arrange.alignRight`,label:`Align right`,alignment:`right`,key:`Alt+KeyD`},{id:`arrange.alignTop`,label:`Align top`,alignment:`top`,key:`Alt+KeyW`},{id:`arrange.alignMiddle`,label:`Align vertical centers`,alignment:`middle`,key:`Alt+KeyV`},{id:`arrange.alignBottom`,label:`Align bottom`,alignment:`bottom`,key:`Alt+KeyS`}],lF=[{id:`arrange.distributeHorizontal`,label:`Distribute horizontal spacing`,axis:`horizontal`,key:`Control+Alt+KeyH`},{id:`arrange.distributeVertical`,label:`Distribute vertical spacing`,axis:`vertical`,key:`Control+Alt+KeyV`}];function uF(e){let{selection:t,mode:n,live:r}=e,i=()=>n.getState().mode===`edit`,a=()=>{let{page:n,frames:r}=t.getState();return n===e.page()?e.frames().filter(e=>r.includes(e.ref)):[]},o=e=>()=>{let t=a();return i()&&r.getState().canWrite&&t.length>=e&&t.every(e=>!e.locked)},s=null,c,l=()=>{clearTimeout(c);let t=s;s=null,t&&e.write(t.page,t.boxes,t.started)},u=t=>{let n=a(),r=e.page(),i=n.map(e=>e.ref);s&&(s.page!==r||!fF(s.refs,i))&&l(),s||={page:r,refs:i,started:pF(n),boxes:pF(n)};let{boxes:o}=s;for(let e of n){let n=o[e.ref]??e.box;o[e.ref]=t(n)}e.hold(o),clearTimeout(c),c=setTimeout(l,300)},d=t=>{let n=pF(a()),r=t(n),i=Object.keys(r).filter(e=>{let t=r[e],i=n[e];return t&&i&&(t.x!==i.x||t.y!==i.y)});e.write(e.page(),mF(r,i),mF(n,i))};return[{id:`selection.clear`,label:`Clear selection`,group:`selection`,keys:[`Escape`],enabled:()=>i()&&t.getState().frames.length>0,run:()=>uD(t)},{id:`selection.all`,label:`Select all`,group:`selection`,command:{label:`Select all`},keys:[`$mod+KeyA`],enabled:()=>i()&&e.frames().length>0,run:()=>sD(t,e.page(),e.frames().map(e=>e.ref))},...sF.flatMap(({name:e,key:t,dx:n,dy:r})=>[{id:`frame.nudge${e}`,label:`Nudge ${e.toLowerCase()}`,group:`frame`,keys:[t],enabled:o(1),run:()=>u(e=>({...e,x:e.x+n,y:e.y+r}))},{id:`frame.nudge${e}Far`,label:`Nudge ${e.toLowerCase()} 10 px`,group:`frame`,keys:[`Shift+${t}`],enabled:o(1),run:()=>u(e=>({...e,x:e.x+n*10,y:e.y+r*10}))},{id:`frame.resize${e}`,label:n===0?r>0?`Make taller`:`Make shorter`:n>0?`Make wider`:`Make narrower`,group:`frame`,keys:[`$mod+${t}`],enabled:o(1),run:()=>u(e=>({...e,width:Math.max(1,e.width+n),height:Math.max(1,e.height+r)}))}]),...cF.map(({id:e,label:t,alignment:n,key:r})=>({id:e,label:t,group:`arrange`,command:{label:t},keys:[r],enabled:o(2),run:()=>d(e=>aF(e,n))})),...lF.map(({id:e,label:t,axis:n,key:r})=>({id:e,label:t,group:`arrange`,command:{label:t},keys:[r],enabled:o(3),run:()=>d(e=>oF(e,n))}))]}function dF(e,t){let n=(0,y.useRef)(e),r=(0,y.useRef)(t);(0,y.useEffect)(()=>{n.current=e,r.current=t},[e,t]),(0,y.useEffect)(()=>{let e=be(uF({page:()=>n.current,frames:()=>ME(r.current),selection:bD,mode:iD,live:yl,hold:PE,write:IE})),t=[bD.subscribe(xe),yl.subscribe(xe)];return()=>{for(let e of t)e();e()}},[])}function fF(e,t){return e.length===t.length&&e.every(e=>t.includes(e))}function pF(e){return Object.fromEntries(e.map(e=>[e.ref,e.box]))}function mF(e,t){return Object.fromEntries(t.flatMap(t=>{let n=e[t];return n?[[t,n]]:[]}))}function hF(e,t,n){let r=6/n,i=(e,t)=>Math.abs(e-t)<=r,a=i(t.x,e.x),o=i(t.x,e.x+e.width),s=i(t.y,e.y),c=i(t.y,e.y+e.height);return s&&a?`nw`:s&&o?`ne`:c&&a?`sw`:c&&o?`se`:null}function gF(e,t,n){let r=6/n,i=(e,t,n)=>e>=t-r&&e<=n+r,a=(e,t)=>Math.abs(e-t)<=r,o=e.x+e.width,s=e.y+e.height;return i(t.x,e.x,o)&&(a(t.y,e.y)||a(t.y,s))||i(t.y,e.y,s)&&(a(t.x,e.x)||a(t.x,o))}function _F(e){let t=e.querySelector(`[data-element-selection]`);if(!t)return null;let{left:n,top:r,width:i,height:a}=t.style;return{x:parseFloat(n),y:parseFloat(r),width:parseFloat(i),height:parseFloat(a)}}function vF(e,t,n){let r=20/n;for(let n=e.length-1;n>=0;--n){let i=e[n];if(!i||i.hidden)continue;let{x:a,y:o,width:s,height:c}=i.box;if(t.x>=a&&t.x<=a+s&&t.y>=o-r&&t.y<=o+c)return i}return null}function yF(e,t){return e.filter(({hidden:e,box:n})=>!e&&n.x<=t.x+t.width&&n.x+n.width>=t.x&&n.y<=t.y+t.height&&n.y+n.height>=t.y)}function bF(e,t,n){let r=n.width/t.width,i=n.height/t.height;return Object.fromEntries(Object.entries(e).map(([e,a])=>{let o=Math.round(n.x+(a.x-t.x)*r),s=Math.round(n.y+(a.y-t.y)*i),c=Math.round(n.x+(a.x+a.width-t.x)*r),l=Math.round(n.y+(a.y+a.height-t.y)*i);return[e,{x:o,y:s,width:Math.max(1,c-o),height:Math.max(1,l-s)}]}))}function xF(e,t,n,r){let i=t===`nw`||t===`sw`,a=t===`nw`||t===`ne`,o=Math.round(e.x),s=Math.round(e.y),c=Math.round(e.x+e.width),l=Math.round(e.y+e.height),u=i?Math.min(Math.round(o+n),c-1):o,d=a?Math.min(Math.round(s+r),l-1):s;return{x:u,y:d,width:i?c-u:Math.max(1,Math.round(c+n)-o),height:a?l-d:Math.max(1,Math.round(l+r)-s)}}var SF=[`start`,`center`,`end`];function CF(e,t,n){let r=TF(e,t,`x`,SF,n),i=TF(e,t,`y`,SF,n);return DF({...e,x:Math.round(e.x+(r?.delta??0)),y:Math.round(e.y+(i?.delta??0))},r,i)}function wF(e,t,n,r){let i=TF(e,n,`x`,[t.x],r),a=TF(e,n,`y`,[t.y],r),o={...e},s=Math.round(i?.delta??0),c=Math.round(a?.delta??0);return t.x===`start`?(o.x+=s,o.width-=s):o.width+=s,t.y===`start`?(o.y+=c,o.height-=c):o.height+=c,o.width<1||o.height<1?{box:e,guides:[],gaps:[]}:DF(o,i,a)}function TF(e,t,n,r,i){let a=null;for(let o of r.map(t=>EF(e,n,t)))for(let e of t)for(let t of SF.map(t=>EF(e,n,t))){let n=t-o;Math.abs(n)>i||a&&Math.abs(n)>Math.abs(a.delta)||(a&&n===a.delta&&t===a.at?a.targets.includes(e)||a.targets.push(e):a={delta:n,at:t,targets:[e]})}return a}function EF(e,t,n){let r=t===`x`?e.x:e.y,i=t===`x`?e.width:e.height;return n===`start`?r:n===`end`?r+i:r+i/2}function DF(e,t,n){let r=[];if(t){let n=[e,...t.targets];r.push({axis:`x`,at:t.at,from:Math.min(...n.map(e=>e.y)),to:Math.max(...n.map(e=>e.y+e.height))})}if(n){let t=[e,...n.targets];r.push({axis:`y`,at:n.at,from:Math.min(...t.map(e=>e.x)),to:Math.max(...t.map(e=>e.x+e.width))})}let i=[],a=n?OF(e,n.targets,`x`):null;a&&i.push(a);let o=t?OF(e,t.targets,`y`):null;return o&&i.push(o),{box:e,guides:r,gaps:i}}function OF(e,t,n){let r=null,i=e=>n===`x`?e.x:e.y,a=e=>i(e)+(n===`x`?e.width:e.height),o=n===`x`?e.y+e.height/2:e.x+e.width/2;for(let s of t){let t=a(s)<=i(e)?{from:a(s),to:i(e)}:a(e)<=i(s)?{from:a(e),to:i(s)}:null;!t||t.to-t.from<=0||r&&r.to-r.from<=t.to-t.from||(r={axis:n,at:o,...t})}return r}var kF={selection:bD,mode:iD,canWrite:()=>yl.getState().canWrite,write:IE};function AF(e,t,n=kF){let{selection:r,mode:i}=n,a={kind:`none`},o={x:0,y:0},s={x:0,y:0},c=!1,l=null,u=new Map,d=()=>t.layer.querySelector(`[data-overlay]`),f=()=>sN(t.viewport).k,p=e=>{let[n,r]=Vk(e,t.viewport),{x:i,y:a,k:o}=sN(t.viewport);return{x:(n-i)/o,y:(r-a)/o}},m=e=>{let{page:n,frames:i}=r.getState();return n===t.page?e.filter(e=>i.includes(e.ref)):[]},h=e=>Object.fromEntries(e.map(e=>[e.ref,e.box])),g=e=>{let n=ME(t.frames()),i=p(e);o=i,s={x:e.clientX,y:e.clientY},c=!1,l=e;let u=r.getState().element,d=u?_F(t.layer):null;if(d&&gF(d,i,f())){a={kind:`none`};return}let g=m(n),_=DE(g.map(e=>e.box)),v=_&&!u?hF(_,i,f()):null;if(_&&v){a={kind:`resize`,corner:v,boxes:h(g),bounds:_};return}let y=vF(n,i,f());y?(!e.shiftKey&&!g.some(({ref:e})=>e===y.ref)&&sD(r,t.page,[y.ref]),a={kind:`press`,frame:y,shift:e.shiftKey}):a={kind:`marquee`,shift:e.shiftKey,base:e.shiftKey?r.getState().frames:[]}},_=()=>{if(a.kind===`press`||a.kind===`resize`){if(a.kind===`press`){let{frame:e,shift:i}=a;i&&!r.getState().frames.includes(e.ref)&&lD(r,t.page,e.ref);let o=m(ME(t.frames())),s=DE(o.map(({box:e})=>e));a=s&&o.every(({locked:e})=>!e)&&n.canWrite()?{kind:`move`,boxes:h(o),bounds:s}:{kind:`none`}}else{let e=Object.keys(a.boxes);(t.frames().some(t=>e.includes(t.ref)&&t.locked)||!n.canWrite())&&(a={kind:`none`})}(a.kind===`move`||a.kind===`resize`)&&(u=new Map(Object.keys(a.boxes).flatMap(e=>{let n=t.layer.querySelector(`[data-frame="${CSS.escape(e)}"]`);return n?[[e,n]]:[]})))}},v=e=>{let n=d();if(!n)return;let r=p(e),i=r.x-o.x,s=r.y-o.y,c=e.ctrlKey?-1:6/f(),l=()=>ME(t.frames()).filter(e=>!(`boxes`in a&&e.ref in a.boxes)).map(e=>e.box);switch(a.kind){case`move`:{let{bounds:e,boxes:t}=a,r=CF({...e,x:Math.round(e.x+i),y:Math.round(e.y+s)},l(),c),o=r.box.x-e.x,d=r.box.y-e.y;for(let[e,n]of Object.entries(t)){let t=u.get(e);t&&(t.style.left=`${n.x+o}px`,t.style.top=`${n.y+d}px`)}KN(n,o,d,r.box),YN(n,r.guides,r.gaps);return}case`resize`:{let{bounds:e,boxes:t,corner:r}=a,o=wF(xF(e,r,i,s),{x:r.endsWith(`w`)?`start`:`end`,y:r.startsWith(`n`)?`start`:`end`},l(),c),d=bF(t,e,o.box);for(let[e,t]of Object.entries(d)){let n=u.get(e);n&&Object.assign(n.style,{left:`${t.x}px`,top:`${t.y}px`,width:`${t.width}px`,height:`${t.height}px`})}qN(n,d),YN(n,o.guides,o.gaps);return}case`marquee`:{let e=jF(o,r);JN(n,e,yF(ME(t.frames()),e).map(e=>e.box));return}default:return}},y=e=>{let i=d();if(!c){a.kind===`press`?a.shift?lD(r,t.page,a.frame.ref):sD(r,t.page,[a.frame.ref]):a.kind===`marquee`&&!a.shift&&uD(r),a={kind:`none`};return}i&&XN(i);let s=p(e);if(a.kind===`marquee`){let e=yF(ME(t.frames()),jF(o,s)).map(e=>e.ref);sD(r,t.page,[...a.base,...e])}else if(a.kind===`move`||a.kind===`resize`){let e={},r={};for(let[t,n]of Object.entries(a.boxes)){let i=u.get(t);if(!i)continue;let a={x:parseFloat(i.style.left),y:parseFloat(i.style.top),width:parseFloat(i.style.width),height:parseFloat(i.style.height)};EE(a,n)||(e[t]=a,r[t]=n)}n.write(t.page,e,r)}a={kind:`none`},u=new Map},b=e=>{e.key===`Control`&&c&&l&&v(new MouseEvent(`mousemove`,{clientX:l.clientX,clientY:l.clientY,ctrlKey:e.type===`keydown`}))},x=oA().container(()=>t.viewport).filter(e=>{let{mode:t,tool:n}=i.getState();return e.button===0&&t===`edit`&&n===`move`}).touchable(!1).on(`start`,e=>{g(e.sourceEvent),addEventListener(`keydown`,b),addEventListener(`keyup`,b)}).on(`drag`,e=>{let t=e.sourceEvent;if(l=t,!c){if(Math.hypot(t.clientX-s.x,t.clientY-s.y)<=3)return;c=!0,_()}v(t)}).on(`end`,e=>{removeEventListener(`keydown`,b),removeEventListener(`keyup`,b),y(e.sourceEvent),l=null}),S=e=>{e.ctrlKey&&e.button===0&&e.preventDefault()},C=zk(e);return C.call(x),e.addEventListener(`contextmenu`,S),()=>{C.on(`.drag`,null),e.removeEventListener(`contextmenu`,S),removeEventListener(`keydown`,b),removeEventListener(`keyup`,b)}}function jF(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(e.x-t.x),height:Math.abs(e.y-t.y)}}var MF={$mod:`⌘`,Meta:`⌘`,Control:`⌃`,Alt:`⌥`,Shift:`⇧`},NF=[`Control`,`Alt`,`Shift`,`$mod`,`Meta`],PF={$mod:`Ctrl`,Meta:`Win`,Control:`Ctrl`,Alt:`Alt`,Shift:`Shift`},FF={Backslash:`\\`,Equal:`=`,Minus:`-`,Escape:`Esc`},IF=/Mac|iPod|iPhone|iPad/.test(navigator.platform);function LF(e,t=IF){return RF(e,t).join(t?``:`+`)}function RF(e,t=IF){let n=e.split(`+`),r=n.pop()??``,i=t?MF:PF,a=t?[...n].sort((e,t)=>NF.indexOf(e)-NF.indexOf(t)):n;return[...(zF(r)?a.filter(e=>e!==`Shift`):a).map(e=>i[e]??e),BF(r)]}function zF(e){return e.length===1&&!/[a-z0-9]/i.test(e)}function BF(e){return FF[e]||(/^(?:Key|Digit)(.)$/.exec(e)?.[1]??e).toUpperCase()}function VF(){return ue()(()=>({held:0}))}var HF=VF(),UF=ue()(()=>({ref:null,surface:`layers`}));function WF(e){return fe(UF,t=>t.surface===e?t.ref:null)}function GF(e,t){UF.setState({ref:e,surface:t})}function KF(){UF.setState({ref:null})}async function qF(e,t,n=WE,r=bD){let{page:i,frames:a}=r.getState();try{let o=await n.renameFrame(e.ref,t);i!==null&&a.includes(e.ref)&&sD(r,i,a.map(t=>t===e.ref?o.ref:t))}catch(t){ZE(`Couldn't rename ${e.name}`)(t)}}function JF(e){let{selection:t,mode:n,live:r,clipboard:i,calls:a}=e,o=()=>n.getState().mode===`edit`&&r.getState().canWrite&&!t.getState().element,s=()=>{let{page:n,frames:r}=t.getState();return n===e.page()?e.frames().filter(e=>r.includes(e.ref)):[]},c=()=>s().map(e=>e.ref),l=()=>o()&&s().length>0,u=()=>l()&&s().every(e=>!e.locked),d=n=>sD(t,e.page(),n.map(e=>e.ref)),f=e=>e.length===1?e[0]?.name??``:`${e.length} frames`,p=(e,t)=>n=>{i.setState(n),E_.add({title:`${e} ${f(t)}`,description:`Paste with ${LF(`$mod+KeyV`)} on any page.`,type:`success`})};return[{id:`frame.rename`,label:`Rename frame`,group:`frame`,command:{label:`Rename frame`,icon:On},enabled:()=>o()&&s().length===1&&!n.getState().hideUi,run:()=>{let[e]=s();e&&(n.setState({tool:`move`}),GF(e.ref,`inspector`))}},{id:`frame.duplicate`,label:`Duplicate`,group:`frame`,command:{label:`Duplicate frame`,icon:Dt},keys:[`$mod+KeyD`],enabled:l,run:()=>{let e=s();a.duplicateFrames(c()).then(d,ZE(`Couldn't duplicate ${f(e)}`))}},{id:`frame.delete`,label:`Delete`,group:`frame`,command:{label:`Delete frame`,icon:ur},keys:[`Backspace`,`Delete`],enabled:u,run:()=>{let e=s();a.deleteFrames(c()).catch(ZE(`Couldn't delete ${f(e)}`))}},{id:`frame.hide`,label:`Hide`,group:`frame`,command:{label:`Hide frame`,icon:jt},keys:[`$mod+Shift+KeyH`],enabled:l,run:()=>{let e=s();a.flagFrames(c(),`hidden`,!0).catch(ZE(`Couldn't hide ${f(e)}`))}},{id:`frame.lock`,label:`Lock`,group:`frame`,command:{label:`Lock or unlock frame`,icon:un},keys:[`$mod+Shift+KeyL`],enabled:l,checked:()=>{let e=s();return e.length>0&&e.every(e=>e.locked)},run:()=>{let e=s(),t=!e.every(e=>e.locked);a.flagFrames(c(),`locked`,t).catch(ZE(`Couldn't ${t?`lock`:`unlock`} ${f(e)}`))}},{id:`frame.copy`,label:`Copy`,group:`frame`,command:{label:`Copy frame`,icon:kt},keys:[`$mod+KeyC`],enabled:l,run:()=>{let e=s();a.copyFrames(c()).then(p(`Copied`,e),ZE(`Couldn't copy ${f(e)}`))}},{id:`frame.cut`,label:`Cut`,group:`frame`,command:{label:`Cut frame`,icon:Wn},keys:[`$mod+KeyX`],enabled:u,run:()=>{let e=s();a.cutFrames(c()).then(p(`Cut`,e),ZE(`Couldn't cut ${f(e)}`))}},{id:`frame.paste`,label:`Paste`,group:`frame`,command:{label:`Paste frames`,icon:Ct},keys:[`$mod+KeyV`],enabled:()=>o()&&i.getState().held>0,run:()=>{a.pasteFrames(e.page()).then(d,ZE(`Couldn't paste`))}}]}function YF(e,t){let n=(0,y.useRef)(e),r=(0,y.useRef)(t);(0,y.useEffect)(()=>{n.current=e,r.current=t},[e,t]),(0,y.useEffect)(()=>{let e=be(JF({page:()=>n.current,frames:()=>r.current,selection:bD,mode:iD,live:yl,clipboard:HF,calls:WE})),t=[bD.subscribe(xe),iD.subscribe(xe),HF.subscribe(xe),yl.subscribe((e,t)=>{!e.connected&&t.connected&&HF.setState({held:0}),xe()})];return()=>{for(let e of t)e();e()}},[])}var XF={phone:{width:390,height:844},tablet:{width:834,height:1194},desktop:{width:1440,height:900}},ZF=`desktop`,QF=ue()(()=>({preset:ZF}));function $F(){return fe(QF,e=>e.preset)}function eI(e){QF.setState({preset:e})}var tI=`frame`;async function nI(e,{page:t,frames:n,preset:r=QF,selection:i=bD,mode:a=iD,calls:o=WE}){let s=KE(tI,n.map(e=>e.name));try{sD(i,t,[(await o.addFrame(`${t}/${s}`,r.getState().preset,Math.round(e.x),Math.round(e.y))).ref]),a.setState({tool:`move`})}catch(e){ZE(`Couldn't add a frame`)(e)}}var rI=()=>yl.getState().canWrite;function iI(){(0,y.useEffect)(()=>{let e=be([{id:`tool.frame`,label:`Frame`,group:`tool`,command:{label:`Add a frame`,icon:Ut},keys:[`f`],enabled:rI,run:()=>iD.setState({tool:`frame`,mode:`edit`}),checked:()=>iD.getState().mode===`edit`&&iD.getState().tool===`frame`}]),t=yl.subscribe((e,t)=>{e.canWrite!==t.canWrite&&(xe(),!e.canWrite&&iD.getState().tool===`frame`&&iD.setState({tool:`move`}))});return()=>{t(),e()}},[])}function aI(){return ue()(()=>({at:null,frame:null}))}var oI=aI();function sI(e){let{place:t,selection:n,mode:r,live:i,clipboard:a,theme:o,notes:s,calls:c}=e,l=()=>r.getState().mode===`edit`,u=()=>l()&&i.getState().canWrite,d=()=>{let{page:t,frames:r}=n.getState();return t===e.page()?r:[]},f=()=>{let e=d(),n=t.getState().frame;return n&&e.includes(n)?n:e[0]},p=()=>{let e=f();return e?W_(ev(e,o)):null};return[{id:`frame.flipTheme`,get label(){let e=p();return e?`Flip to ${e}`:`Flip frame theme`},group:`frame`,command:{label:`Flip frame theme`,icon:Qn},enabled:()=>l()&&d().length>0,run:()=>{let e=p();if(e)for(let t of d())ev(t,o)!==e&&$_(t,o)}},{id:`frame.pasteAt`,label:`Paste here`,group:`frame`,enabled:()=>u()&&a.getState().held>0&&t.getState().at!==null,run:()=>{let{at:r}=t.getState();if(!r)return;let i=e.page();c.pasteFrames(i,{x:Math.round(r.x),y:Math.round(r.y)}).then(e=>sD(n,i,e.map(e=>e.ref)),ZE(`Couldn't paste`))}},{id:`frame.newAt`,label:`New frame here`,group:`frame`,enabled:()=>u()&&t.getState().at!==null,run:()=>{let{at:i}=t.getState();i&&nI(i,{page:e.page(),frames:e.frames(),preset:e.preset,selection:n,mode:r,calls:c})}},{id:`note.addHere`,label:`Add a note here`,group:`note`,enabled:()=>u()&&!!n.getState().element&&d().length>0&&t.getState().at!==null,run:()=>{let{at:i}=t.getState(),{element:a}=n.getState(),o=e.frames().find(e=>e.ref===a?.frame);if(!i||!a||!o)return;let c=e.renderedAt(o.ref);r.setState({tool:`note`}),s.setState({open:{kind:`new`,pick:{frame:{ref:o.ref,name:o.name},element:c?a.index:null,renderedAt:c,at:i}}})}}]}function cI(e,t,n){let r=(0,y.useRef)(e),i=(0,y.useRef)(t),a=(0,y.useRef)(n);(0,y.useEffect)(()=>{r.current=e,i.current=t,a.current=n},[e,t,n]),(0,y.useEffect)(()=>{let e=be(sI({page:()=>r.current,frames:()=>i.current,renderedAt:e=>a.current(e),place:oI,selection:bD,mode:iD,live:yl,clipboard:HF,theme:ov,preset:QF,notes:TP,calls:WE})),t=[oI.subscribe(xe),ov.subscribe(xe),bD.subscribe(xe),iD.subscribe(xe),HF.subscribe(xe),yl.subscribe(xe)];return()=>{for(let e of t)e();e()}},[])}var lI=y.createContext(void 0);function uI(e=!0){let t=y.useContext(lI);if(t===void 0&&!e)throw Error(Ds(25));return t}var dI=y.createContext(void 0);function fI(e){let t=y.useContext(dI);if(t===void 0&&!e)throw Error(Ds(33));return t}var pI=y.createContext(void 0);function mI(e){let t=y.useContext(pI);if(t===void 0&&!e)throw Error(Ds(36));return t}function hI({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=y.useRef(e!==void 0),[a,o]=y.useState(()=>t);return[i&&e!==void 0?e:a,y.useCallback(e=>{i||o(e)},[])]}var gI=y.createContext(null);function _I(e=`root`){let t=y.useContext(gI),n=y.useContext(pI);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var vI={visible:!0,ref:null};function yI(){return vI}function bI(e,t,n=`root`){let r=_I(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??yI)({label:e.label,children:e.children,render:e.render}),a=Is(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}function xI(e){e.preventDefault()}function SI(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=mI(),u=uI(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return y.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?xI:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:Rp})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!Ou&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&Ms(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var CI={type:`regular-item`};function wI(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=y.useRef(null),{getButtonProps:d,buttonRef:f}=Ns({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=SI({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=y.useCallback(e=>ps(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=Is(u,f);return y.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var TI=y.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function EI(){return y.useContext(TI)}function DI(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=EI(),u=y.useRef(-1),[d,f]=y.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=y.useRef(null),h=y.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return Y(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}function OI(e){return Cp(e,`base-ui`)}var kI=`data-checked`,AI=`data-unchecked`,jI={checked(e){return e?{[kI]:``}:{[AI]:``}},...Ku},MI=y.createContext(void 0);function NI(){let e=y.useContext(MI);if(e===void 0)throw Error(Ds(31));return e}var PI=y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=y.useState(void 0),c=Zs(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,G.jsx)(MI.Provider,{value:s,children:c})}),FI=y.forwardRef(function(e,t){let n=_I()?.Group??PI;return(0,G.jsx)(n,{...e,ref:t})}),II=y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=OI(a),c=NI();return Y(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Zs(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),LI=y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=mI(),f=DI({guess:!0,label:a}),p=OI(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=wI({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:CI});return Zs(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),RI=y.forwardRef(function(e,t){let n=bI(e,t);return n.visible?(0,G.jsx)(LI,{...e,ref:n.ref}):null}),zI=y.createContext(void 0);function BI(e){let t=y.useContext(zI);if(t===void 0&&!e)throw Error(Ds(69));return t}var VI=`ArrowUp`,HI=`ArrowDown`,UI=`ArrowLeft`,WI=`ArrowRight`,GI=new Set([VI,HI,UI,WI,`Home`,`End`]),KI=[`Shift`,`Control`,`Alt`,`Meta`];function qI(e){return zo(e)&&e.tagName===`INPUT`}function JI(e){return!!(qI(e)&&e.selectionStart!=null||zo(e)&&e.tagName===`TEXTAREA`)}function YI(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=XI(e,t,`left`),a=ZI(e),o=ZI(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=XI(e,t,`top`),r=ZI(e),i=ZI(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function XI(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function ZI(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}var QI=y.createContext(void 0);function $I(){return y.useContext(QI)}function eL(e,t){let n=tc(e.render);if(y.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function tL(e,t,n){let r=eL(e,t),i=r===t?void 0:r;return[r,y.useCallback(e=>n?.(e?i:void 0),[i,n])]}function nL(e,t,n){let r=tc(e.render),i=y.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var rL=y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=mI(),m=$I(),{side:h,align:g}=fI(),_=BI(!0)!=null,v=l.useState(`open`),b=l.useState(`transitionStatus`),x=l.useState(`popupProps`),S=l.useState(`mounted`),C=l.useState(`instantType`),w=l.useState(`activeTriggerElement`),T=l.useState(`parent`),E=l.useState(`lastOpenChangeReason`),D=l.useState(`rootId`),O=l.useState(`floatingRootContext`),k=l.useState(`floatingTreeRoot`),A=l.useState(`closeDelay`),j=l.useState(`hoverEnabled`),M=l.useState(`disabled`),N=l.useState(`openMethod`),P=l.useState(`activeTriggerId`),F=l.useState(`listElement`),[I,L]=tL(e,u,d),R=nL(e,w,P),z=T.type===`menu`?m:void 0,B=T.type===`context-menu`,ee=s??T.type!==`menu`;s===void 0&&F&&T.type!==`menu`&&(ee=()=>l.state.activeIndex===null&&F),Yf({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),y.useEffect(()=>{function e(e){l.setOpen(!1,jp(e.reason,e.domEvent))}return k.events.on(`close`,e),()=>{k.events.off(`close`,e)}},[k.events,l]),Fh(O,{enabled:j&&!M&&!B&&T.type!==`menubar`,closeDelay:A});let te=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:ne,handleFocus:re}=(y.useContext(gI)?.useParentHandoff??aL)(l,T,v,f),ie=Zs(`div`,e,{state:{transitionStatus:b,side:h,align:g,open:v,nested:T.type===`menu`,instant:C},ref:[t,l.context.popupRef,te,L],stateAttributesMapping:od,props:[x,{id:I,...F?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":R},onKeyDown(e){z?.onPopupKeyDown?.(e),_&&GI.has(e.key)&&e.stopPropagation()},onFocus:re},S_(b),c,{"data-rootownerid":D}]}),V=T.type===void 0||B;(w||T.type===`menubar`&&E!==`outside-press`)&&(V=!0);let H=z?.getReturnElement??ne;return(0,G.jsx)(Km,{context:O,openInteractionType:N,modal:B,disabled:!S,returnFocus:a??H??V,explicitReturnFocus:a===void 0&&H?!1:void 0,initialFocus:ee,restoreFocus:!0,getInsideElements:T.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:T.type===`menubar`?void 0:k,previousFocusableElement:w,nextFocusableElement:T.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:ie})}),iL={parentVirtualFocusRef:void 0,handleFocus:void 0};function aL(){return iL}var oL=y.forwardRef(function(e,t){let n=_I()?.Popup??rL;return(0,G.jsx)(n,{...e,ref:t})}),sL=y.createContext(void 0);function cL(){let e=y.useContext(sL);if(e===void 0)throw Error(Ds(32));return e}var lL=y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=mI();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,G.jsx)(sL.Provider,{value:n,children:(0,G.jsx)(nm,{ref:t,...r,portalOwnerRole:o})})});function uL(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=J(i),[,o]=y.useState(0),s=os(fL).current,c=os(dL).current,l=y.useRef(0),u=y.useRef(!0),d=y.useRef(null),f=y.useRef(null),p=J(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=J((e,t)=>{c.set(e,t),p()}),h=J(e=>{c.delete(e),p()}),g=J(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!hL(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&gL(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=mL(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=J(()=>{let[e,t]=pL(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});Y(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),Y(()=>{u.current&&v()}),Y(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let b=J(e=>(s.add(e),()=>{s.delete(e)})),x=y.useMemo(()=>({register:m,unregister:h,subscribeMapChange:b,nextIndexRef:l}),[m,h,b,l]);return(0,G.jsx)(TI.Provider,{value:x,children:t})}function dL(){return new Map}function fL(){return new Set}function pL(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>gL(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function mL(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function hL(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function gL(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var _L=y.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,G.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function vL(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=y.useRef(null),o=y.useRef(null),s=Jf(r);Y(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),Y(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}var yL={},bL={},xL=``;function SL(e,t){return Vo(e)?e:t}function CL(e,t,n){return/hidden|clip/.test(e.getComputedStyle(SL(t,n)).overflowY)}function wL(e){if(typeof document>`u`)return!1;let t=js(e);return Lo(t).innerWidth-t.documentElement.clientWidth>0}function TL(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=js(e),n=t.documentElement,r=t.body,i=SL(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function EL(e){let t=js(e),n=t.documentElement,r=t.body,i=SL(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function DL(e){let t=js(e),n=t.documentElement,r=t.body,i=Lo(n),a=0,o=0,s=!1,c=du.create();if(Au&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,yL={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},xL=n.style.scrollBehavior,bL={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=SL(n,r);s=TL(e),s?(n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`):(Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`)}function u(){Object.assign(n.style,yL),Object.assign(r.style,bL),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=xL)}function d(){u(),c.request(l)}l();let f=su(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var OL=new class{lockCount=0;restore=null;timeoutLock=mu.create();timeoutUnlock=mu.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=js(e),n=t.documentElement,r=t.body,i=Lo(n);if(CL(i,n,r)){let t=new i.MutationObserver(()=>{CL(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Tu||!wL(e);this.restore=a?EL(e):DL(e)}};function kL(e=!0,t=null){Y(()=>{if(e)return OL.acquire(t)},[e,t])}var AL=20;function jL(e,t,n,r){let[i,a]=y.useState(!1);Y(()=>{if(!e||!t||n==null){a(!1);return}let r=js(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-AL)},[e,t,n]),kL(e&&(!t||i),r)}var ML=y.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=tp,style:g,..._}=e,{store:v,virtualFocus:b,syncHighlightedItem:x}=mI(),S=cL(),C=uI(!0),w=v.useState(`parent`),T=v.useState(`floatingRootContext`),E=v.useState(`floatingTreeRoot`),D=v.useState(`mounted`),O=v.useState(`open`),k=v.useState(`modal`),A=v.useState(`openMethod`),j=v.useState(`activeTriggerElement`),M=v.useState(`transitionStatus`),N=v.useState(`positionerElement`),P=v.useState(`instantType`),F=v.useState(`adaptiveOrigin`),I=v.useState(`lastOpenChangeReason`),L=v.useState(`floatingNodeId`),R=v.useState(`floatingParentNodeId`),z=T.useState(`domReferenceElement`),B=n,ee=c,te=l,ne=s,re=h;w.type===`context-menu`&&(B=n??w.context?.anchor,ne??=`start`,!o&&ne!==`center`&&(te=e.alignOffset??2,ee=e.sideOffset??-5));let ie=o,V=ne;w.type===`menu`?(ie??=`inline-end`,V??=`start`,re=e.collisionAvoidance??np):w.type===`menubar`&&(ie??=w.context.orientation===`vertical`?`inline-end`:`bottom`,V??=`start`);let H=w.type===`context-menu`,ae=y_({anchor:B,floatingRootContext:T,positionMethod:C?`fixed`:r,mounted:D,side:ie,sideOffset:ee,align:V,alignOffset:te,arrowPadding:H?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:L,keepMounted:S,disableAnchorTracking:m,collisionAvoidance:re,shift:H?{crossAxis:!(`side`in re&&re.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:E,adaptiveOrigin:F,lazyFlip:b?`placement`:!1});y.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===L&&v.set(`hoverEnabled`,!1),e.nodeId!==L&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,jp(Kp)))}return E.events.on(`menuopenchange`,e),()=>{E.events.off(`menuopenchange`,e)}},[v,E.events,L]),y.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,jp(t))}return E.events.on(`menuopenchange`,e),()=>{E.events.off(`menuopenchange`,e)}},[E.events,v]);let oe=hu();y.useEffect(()=>{O||oe.clear()},[O,oe]),y.useEffect(()=>{function e(e){if(O&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&j&&j!==e.target){let e=v.select(`closeDelay`);e>0?oe.isStarted()||oe.start(e,()=>{v.setOpen(!1,jp(Kp))}):v.setOpen(!1,jp(Kp))}else oe.clear()}}return E.events.on(`itemhover`,e),()=>{E.events.off(`itemhover`,e)}},[E.events,O,j,v,oe]),y.useEffect(()=>{let e={open:O,nodeId:L,parentNodeId:R,reason:v.select(`lastOpenChangeReason`)};E.events.emit(`menuopenchange`,e)},[E.events,O,v,L,R]),vL({store:v,domReference:z,positionerElement:N,open:O});let se={open:O,side:ae.side,align:ae.align,anchorHidden:ae.anchorHidden,nested:w.type===`menu`,instant:P},U=w.type===`menubar`&&w.context.modal;jL(O&&(U||k&&I!==`trigger-hover`),A===`touch`,N,j);let ce=C_(e,se,{styles:ae.positionerStyles,transitionStatus:M,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!D,inert:!O}),le=D&&w.type!==`menu`&&(w.type!==`menubar`&&k&&I!==`trigger-hover`||w.type===`menubar`&&w.context.modal),ue=null;return w.type===`menubar`?ue=w.context.contentElement:w.type===void 0&&(ue=j),(0,G.jsxs)(dI.Provider,{value:ae,children:[le&&(0,G.jsx)(_L,{ref:w.type===`context-menu`||w.type===`nested-context-menu`?w.context.internalBackdropRef:null,inert:Bf(!O),cutout:ue}),(0,G.jsx)(Im,{id:L,children:(0,G.jsx)(uL,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:x,children:ce})})]})}),NL=y.createContext(void 0);function PL(){let e=y.useContext(NL);if(e===void 0)throw Error(Ds(34));return e}var FL=y.forwardRef(function(e,t){let{render:n,className:r,value:i,defaultValue:a,onValueChange:o,disabled:s=!1,style:c,"aria-labelledby":l,...u}=e,[d,f]=y.useState(void 0),[p,m]=hI({controlled:i,default:a,name:`MenuRadioGroup`}),h=J((e,t)=>{o?.(e,t),!t.isCanceled&&m(e)}),g=Zs(`div`,e,{state:{disabled:s},ref:t,props:{role:`group`,"aria-labelledby":l??d,"aria-disabled":s||void 0,...u}}),_=y.useMemo(()=>({value:p,setValue:h,disabled:s}),[p,h,s]);return(0,G.jsx)(MI.Provider,{value:f,children:(0,G.jsx)(NL.Provider,{value:_,children:g})})}),IL=y.memo(y.forwardRef(function(e,t){let n=_I()?.RadioGroup??FL;return(0,G.jsx)(n,{...e,ref:t})})),LL=y.createContext(void 0);function RL(){let e=y.useContext(LL);if(e===void 0)throw Error(Ds(35));return e}var zL=y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,value:l,style:u,...d}=e,{store:f}=mI(),{value:p,setValue:m,disabled:h}=PL(),g=DI({guess:!0,label:a}),_=OI(i),v=f.useState(`isActive`,g.index),b=f.useState(`floatingNodeId`),x=f.useState(`itemProps`),S=f.useState(`disabled`),C=s||h||S,w=p===l,{getItemProps:T,itemRef:E}=wI({closeOnClick:c,disabled:C,highlighted:v,id:_,store:f,nativeButton:o,nodeId:b,itemMetadata:CI}),D=y.useMemo(()=>({disabled:C,highlighted:v,checked:w}),[C,v,w]);function O(e){let t=jp(Rp,e.nativeEvent,void 0,{preventUnmountOnClose:Gs});m(l,t)}let k=Zs(`div`,e,{state:D,stateAttributesMapping:jI,props:[x,{role:`menuitemradio`,"aria-checked":w,onClick:O},d,T],ref:[E,t,g.ref]});return(0,G.jsx)(LL.Provider,{value:D,children:k})}),BL=y.forwardRef(function(e,t){let n=bI(e,t);return n.visible?(0,G.jsx)(zL,{...e,ref:n.ref}):null}),VL=y.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=RL(),c=y.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=th(s.checked);return Yf({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),Zs(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},stateAttributesMapping:jI,ref:[t,c],props:{"aria-hidden":!0,...o},enabled:a||u})}),HL=y.createContext(null);function UL(e){let t=y.useContext(HL);if(t===null&&!e)throw Error(Ds(5));return t}function WL(e){let t=y.useRef(``),n=y.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:y.useCallback(n=>{n.detail===0?e(n,`keyboard`):(`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``)},[e]),onPointerDown:n}}function GL(e,t){let n=y.useRef(e),r=J(t);Y(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function KL(e,t){let{onClick:n,onPointerDown:r}=WL(J((n,r)=>{(typeof e==`function`?e():e)||t(r||(Tu?`touch`:``))}));return y.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function qL(e){let[t,n]=y.useState(null),r=KL(e,n);return GL(e,t=>{t&&!e&&n(null)}),y.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function JL(e){return e==null?Np:e.type.startsWith(`key`)?Up:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?Wp:Np}var YL={...Eh,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=Eh.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Au&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!Eh.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},XL=class extends au{constructor(e,t,n=!1){let r=new _h,i=QL(r,t,n,e);super(i,ZL(r),YL),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function ZL(e){return{positionerRef:y.createRef(),popupRef:y.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:y.createRef(),beforeTriggerFocusGuardRef:y.createRef(),beforeContentFocusGuardRef:y.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function QL(e,t,n=!1,r){return{...bh(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:qs,inputProps:qs,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new Am,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:qs,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var $L=y.createContext(null);function eR(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function tR(e,t){return e===`list-navigation`||eR(e,t)}var nR=Yl(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:b,allowEscape:x=!0,resetOnPointerLeave:S=!0}=e,C=uI(!0),w=mI(!0),T=UL(!0),E=w?.store,D=w?.virtualFocus??!1,O=y.useMemo(()=>_&&E?{type:`menu`,store:E}:T?{type:`menubar`,context:T}:C&&!E?{type:`context-menu`,context:C}:{type:void 0},[C,E,T,_]),k=OI(),A=OI(),[j,M]=y.useState(void 0),N=(j??A)||void 0,P=Nm(),F=O.type===`menu`?O.store:void 0,I=(n??o)&&F?.state.transitionStatus===`starting`,L=os(()=>I?F?.state.instantType:void 0).current,R=os(()=>{let e=new XL({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:O,disabled:s,highlightItemOnHover:g,modal:O.type===void 0?c:void 0,rootId:k,instantType:L},N,P!=null);return e.context.virtualFocusRef=b,e}).current;R.useControlledProp(`openProp`,n),R.useControlledProp(`triggerIdProp`,m),R.useContextCallback(`onOpenChangeComplete`,i);let z=R.useState(`floatingTreeRoot`),B=Fm(z),ee=R.useState(`open`),te=R.useState(`activeTriggerElement`),ne=R.useState(`positionerElement`),re=R.useState(`hoverEnabled`),ie=R.useState(`disabled`),V=R.useState(`lastOpenChangeReason`),H=R.useState(`parent`),ae=R.useState(`activeIndex`),oe=R.useState(`keyboardOpen`),se=R.useState(`payload`),U=R.useState(`floatingParentNodeId`),ce=y.useRef(null),le=y.useRef(H.type!==`context-menu`),ue=hu(),de=y.useRef(!0),fe=hu(),pe=U!=null,{openMethod:me,triggerProps:he}=qL(ee);R.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:H.type===void 0?c:void 0,openMethod:me,rootId:k}),ph(R);let{forceUnmount:ge,transitionStatus:_e}=mh(ee,R,()=>{R.set(`allowMouseEnter`,!1)},I),ve=Jf(R.context.popupRef);y.useEffect(()=>{if(L===void 0)return;let e=()=>{R.state.instantType===L&&R.set(`instantType`,void 0)};if(!ee){e();return}if(_e!==void 0)return;if(R.context.popupRef.current==null){e();return}let t=new AbortController;return ve(e,t.signal),()=>{t.abort()}},[L,ee,_e,ve,R]),Y(()=>{C&&!w?R.update({parent:{type:`context-menu`,context:C},floatingNodeId:B,floatingParentNodeId:P}):(w||!R.select(`activeTriggerElement`))&&R.update({floatingNodeId:B,floatingParentNodeId:P})},[C,w,B,P,te,R]),y.useEffect(()=>{ee||(ce.current=null),H.type===`context-menu`&&(ee?ue.start(500,()=>{le.current=!0}):(ue.clear(),le.current=!1))},[ue,ee,H.type]),Y(()=>{!ee&&!re&&R.set(`hoverEnabled`,!0)},[ee,re,R]);let ye=J((e,t)=>{let n=t.reason;if(!e&&!R.select(`open`)||ee===e&&t.trigger===te&&V===n)return;let i=uh(t);if(!e&&t.trigger==null&&(t.trigger=te??void 0),r?.(e,t),t.isCanceled)return;R.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!de.current)return;e&&n===`trigger-focus`?(de.current=!1,fe.start(300,()=>{de.current=!0})):(de.current=!0,fe.clear());let o=!e&&(n===`escape-key`||n==null);ce.current=t.event;let s=lh(R.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&tR(n,a),s.instantType=H.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:eR(n,a)?`click`:o?`dismiss`:void 0,R.update(s)}),be=eh({popupStore:R,floatingRootContext:R.state.floatingRootContext,floatingId:N,nested:P!=null,onOpenChange:ye}),xe=be.context.events;Y(()=>{let e=({open:e,eventDetails:t})=>ye(e,t);return xe.on(`setOpen`,e),()=>{xe?.off(`setOpen`,e)}},[xe,ye]),Y(()=>R.subscribeToParentMenu(),[R]);let Se=y.useCallback(()=>{R.setOpen(!1,jp(Xp))},[R]);y.useImperativeHandle(d,()=>({unmount:ge,close:Se}),[ge,Se]);let Ce;H.type===`context-menu`&&(Ce=H.context),y.useImperativeHandle(Ce?.positionerRef,()=>ne,[ne]),y.useImperativeHandle(Ce?.actionsRef,()=>({setOpen:ye}),[ye]);let we=$m(be,{enabled:!ie,bubbles:{escapeKey:f&&H.type===`menu`},outsidePress(){return H.type!==`context-menu`||ce.current?.type===`contextmenu`||le.current},externalTree:pe?z:void 0}),Te=a_(),Ee=Wh(be,{enabled:!ie,listRef:R.context.itemDomElements,activeIndex:ae,virtual:v,nested:H.type===`menubar`||!v&&H.type!==void 0,parentOrientation:H.type===`menubar`?H.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?oe:void 0,allowEscape:v&&l&&x,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Te===`rtl`,disabledIndices:Ks,onNavigate(e,t){R.setActiveIndex(e,JL(t),t?.nativeEvent)},openOnArrowKeyDown:H.type!==`context-menu`&&!(v&&_),externalTree:!v&&pe?z:void 0,nestedReturnFocusRef:F?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:S}),De=y.useCallback(e=>{R.context.typingRef.current=e},[R]),Oe=Gh(be,{enabled:!ie&&!v,listRef:R.context.itemLabels,elementsRef:R.context.itemDomElements,activeIndex:ae,resetMs:500,onMatch:(e,t)=>{ee&&e!==ae&&R.setActiveIndex(e,Up,t.nativeEvent)},onTyping:De}),ke=J(a),Ae=y.useRef(-1),je=J(()=>{let e=R.state.activeIndex,t=e===null?void 0:R.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Ae.current===n&&R.context.reportedItem===t)return;Ae.current=n,R.context.reportedItem=t,v&&R.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=R.context;R.context.highlightReason=Np,R.context.highlightEvent=void 0,a&&ke(t,Mp(r,i,{label:t===void 0?void 0:R.context.itemLabels.current[n]??void 0}))});Y(()=>{je()},[ae,je]);let Me=y.useMemo(()=>{if(!v)return Ee.reference;if(!Ee.trigger)return qs;let{onFocus:e,...t}=Ee.trigger;return t},[v,Ee.reference,Ee.trigger]);R.useSyncedValue(`inputProps`,v?Ee.reference??qs:qs);let Ne=y.useMemo(()=>{let e=ps(Oe.reference,Me,we.reference,{onMouseMove(){R.set(`allowMouseEnter`,!0)}},he);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=ee,e},[R,Oe.reference,Me,we.reference,he,ee]),Pe=y.useMemo(()=>{let e=ps(Ee.trigger,we.trigger,he);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Ee.trigger,we.trigger,he]);os(()=>(R.update({inactiveTriggerProps:Pe}),null)),hh(R,{floatingRootContext:be,activeTriggerProps:Ne,inactiveTriggerProps:Pe,popupProps:y.useMemo(()=>ps(rh,{onMouseMove(){R.set(`allowMouseEnter`,!0),H.type===`menu`&&R.set(`hoverEnabled`,!1)},onClick(){R.select(`hoverEnabled`)&&R.set(`hoverEnabled`,!1)},onKeyDown(e){let t=R.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Oe.floating,Ee.floating,we.floating),[H.type,R,Oe.floating,Ee.floating,we.floating]),itemProps:Ee.item??qs});let Fe=y.useMemo(()=>({store:R,parent:O,orientation:u,loopFocus:l,allowEscape:x,defaultFloatingId:A,setRenderedFloatingId:M,virtualFocus:v,parentVirtualFocus:D,syncHighlightedItem:je}),[R,O,u,l,x,A,v,D,je]),Ie=typeof t==`function`?t({payload:se}):t,Le=(0,G.jsxs)(pI.Provider,{value:Fe,children:[p&&(0,G.jsx)(oh,{handle:p,store:R}),Ie]});return(H.type===void 0||H.type===`context-menu`)&&(Le=(0,G.jsx)(Lm,{externalTree:z,children:Le})),Le});function rR(e){let t=y.useContext($L);if(t===null)return(0,G.jsx)(nR,{...e});let n=t.Root;return(0,G.jsx)($L.Provider,{value:null,children:(0,G.jsx)(n,{...t.options,...e})})}var iR={};function aR(e){mI();let t=y.useContext($L);if(t!==null){let n=t.SubmenuRoot;return(0,G.jsx)($L.Provider,{value:null,children:(0,G.jsx)(n,{...t.options,...e})})}return(0,G.jsx)(QI.Provider,{value:iR,children:(0,G.jsx)(nR,{...e,isSubmenu:!0})})}var oR=5;function sR(e,t){let n=cR(t);return e.clientX>=n.left-oR&&e.clientX<=n.right+oR&&e.clientY>=n.top-oR&&e.clientY<=n.bottom+oR}function cR(e){let t=e.getBoundingClientRect(),n=Lo(e);if(Mu)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function lR(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=ks(),{ref:i,index:a}=DI(e),o=n===a,s=y.useRef(null),c=Is(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function uR(e){let{render:t,className:n,style:r,state:i=qs,props:a=Ks,refs:o=Ks,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=lR({metadata:s});return Zs(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function dR(e){if(zo(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Zo(e))return dR(es(e))}function fR(e,t){function n(n,r,i){let a=n.currentTarget;Gf.flushSync(()=>{e.setOpen(!1,jp(Bp,n.nativeEvent,a))}),Tf(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&Ef(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function pR(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=y.useRef(!1);return y.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,js(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:qs,[t,n,r])}var mR=Xl(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=mI(!0),h=Dh(d)??m?.store;if(!h)throw Error(Ds(85));let g=OI(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),b=h.useState(`isOpenedByTrigger`,g),x=h.useState(`triggerControlsId`,g),S=y.useRef(null),C=gR(),w=ks(!0),T=Pm(),E=y.useMemo(()=>T??new Am,[T]),{registerTrigger:D,isMountedByThisTrigger:O}=fh(g,S,h,{payload:f,closeDelay:u,parent:C,floatingTreeRoot:E,floatingNodeId:Fm(E),floatingParentNodeId:Nm(),keyboardEventRelay:w?.relayKeyboardEvent}),k=C.type===`menubar`,A=h.useState(`disabled`),j=a||A||k&&C.context.disabled,{getButtonProps:M,buttonRef:N}=Ns({disabled:j,native:o});y.useEffect(()=>{!b&&C.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,b,C.type]);let P=y.useRef(null),F=hu(),I=J(e=>{if(!P.current)return;F.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Q(P.current,t)||Q(h.select(`positionerElement`),t)||t===P.current||(t==null||dR(t)!==h.select(`rootId`))&&(sR(e,P.current)||E.events.emit(`close`,{domEvent:e,reason:Gp}))});y.useEffect(()=>{let e=js(P.current);if(b&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,I,{once:!0}),()=>{e.removeEventListener(`mouseup`,I)}},[b,I,h]);let L=k&&C.context.hasSubmenuOpen,R=Lh(v,{enabled:(c??L)&&!j&&(!k||L&&!O),handleClose:$h({blockPointerEvents:!k}),mouseOnly:!0,move:!1,restMs:C.type===void 0?l:void 0,delay:{close:u},triggerElementRef:S,externalTree:E,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),z=hR(b,h.select(`lastOpenChangeReason`)),B=qm(v,{enabled:!j,event:b&&k?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:C.type===void 0&&z}),ee=kh(v,{enabled:!j&&L}),te=pR({open:b,enabled:k,mouseDownAction:`open`}),ne=y.useMemo(()=>ps(ee.reference,B.reference),[ee.reference,B.reference]),re=h.useState(`triggerProps`,O),ie=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:V,handleFocusTargetFocus:H}=fR(h,S),ae={disabled:j,open:b},oe=[P,t,N,D,S],se=[ne,R??qs,re,{"aria-haspopup":`menu`,"aria-controls":x,id:g,onMouseDown:e=>{h.select(`open`)||(F.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),js(e.currentTarget).addEventListener(`mouseup`,I,{once:!0}))}},ie,k?{role:`menuitem`}:{},te,p,M],U=Zs(`button`,e,{enabled:!k,stateAttributesMapping:id,state:ae,ref:oe,props:se});return k?(0,G.jsx)(uR,{tag:`button`,render:n,className:r,style:i,state:ae,refs:oe,props:se,stateAttributesMapping:id}):b?(0,G.jsxs)(y.Fragment,{children:[(0,G.jsx)(Lf,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:V},`${g}-pre-focus-guard`),(0,G.jsx)(y.Fragment,{children:U},g),(0,G.jsx)(Lf,{ref:h.context.triggerFocusTargetRef,onFocus:H},`${g}-post-focus-guard`)]}):(0,G.jsx)(y.Fragment,{children:U},g)});function hR(e,t){let n=hu(),[r,i]=y.useState(!1);return Y(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function gR(){let e=UL(!0);return y.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var _R=y.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Zs(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function vR(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var yR={"aria-expanded":void 0},bR=y.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:l=100,closeDelay:u=0,disabled:d=!1,...f}=e,p=mI(!0);if(p?.parent.type!==`menu`)throw Error(Ds(37));let m=fI(),h=$I(),{store:g,parentVirtualFocus:_}=p,v=p.parent.store,b=DI({guess:!0,label:a}),x=OI(o),S=g.useState(`open`),C=y.useRef(!1),w=g.useState(`positionerElement`),T=g.useState(`floatingRootContext`),E=g.useState(`floatingTreeRoot`),D=g.useState(`triggerPopupId`,x),O=ch(x,g),k=J(e=>{O(e);let t=g.select(`activeTriggerElement`);e!==null&&g.select(`open`)&&(t===e||g.select(`activeTriggerId`)==null)&&g.update({activeTriggerId:x??null,activeTriggerElement:e,closeDelay:u})}),A=y.useRef(null),j=y.useCallback(e=>{A.current=e,g.set(`activeTriggerElement`,e)},[g]);Y(()=>(k(A.current),()=>k(null)),[k,x,g]),Y(()=>{if(!S||!w)return;function e(e){Fu(e)===g.context.beforeContentFocusGuardRef.current&&(C.current=e.relatedTarget===A.current)}return w.addEventListener(`focusout`,e,!0),()=>{C.current=!1,w.removeEventListener(`focusout`,e,!0)}},[S,w,g]),g.useSyncedValue(`closeDelay`,u);let M=g.useState(`disabled`),N=v.useState(`disabled`),P=d||M||N,F=v.useState(`itemProps`),I=v.useState(`isActive`,b.index),L=y.useMemo(()=>({type:`submenu-trigger`,setActive(e){v.select(`highlightItemOnHover`)&&v.setActiveIndex(b.index,Wp,e)}}),[v,b.index]),{getItemProps:R,itemRef:z}=wI({closeOnClick:!1,disabled:P,highlighted:I,id:x,store:g,typingRef:v.context.typingRef,nativeButton:s,itemMetadata:L,nodeId:m?.context.nodeId}),B=Lh(T,{enabled:g.useState(`hoverEnabled`)&&c&&!P,handleClose:$h({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>v.select(`allowMouseEnter`):void 0,triggerElementRef:A,externalTree:E,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),ee=qm(T,{enabled:!P,event:`mousedown`,toggle:!0,ignoreMouse:c,stickIfOpen:c}).reference??qs,te=g.useState(`triggerProps`,!0);delete te.id;let ne={disabled:P,highlighted:I,open:S},re=g.useState(`openMethod`),ie=g.useState(`lastOpenChangeReason`)===`list-navigation`||re===`keyboard`,V=S&&ie&&ju;return Zs(`div`,e,{state:ne,stateAttributesMapping:rd,props:[ee,B,te,h?.onTriggerKeyDown?{onKeyDown:h.onTriggerKeyDown}:void 0,F,V?yR:void 0,{"aria-controls":D,tabIndex:_||!(S||I)?-1:0,onFocus(e){g.select(`open`)&&C.current&&(C.current=!1,g.setOpen(!1,jp(Bp,e.nativeEvent)))},onBlur(){I&&v.setActiveIndex(null,Np)}},f,R],ref:[t,b.ref,z,k,j]})}),xR=y.forwardRef(function(e,t){let n=bI(e,t,`submenu-trigger`);if(!n.visible)return null;let r=n.props?ps(n.props,e):e;return(0,G.jsx)(bR,{...r,ref:n.ref})});function SR(e){let[t,n]=y.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=y.useRef(null),i=y.useRef(null),a=y.useRef(null),o=y.useRef(null),s=y.useRef(!0),c=y.useRef(null),l=Cp(),u=y.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:l}),[t,l]);return(0,G.jsx)(lI.Provider,{value:u,children:(0,G.jsx)(pI.Provider,{value:void 0,children:(0,G.jsx)(rR,{...e})})})}var CR=500,wR=y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:l,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:f,rootId:p}=uI(!1),{store:m}=mI(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=y.useRef(null),v=y.useRef(null),b=hu(),x=hu(),S=y.useRef(!1),C=y.useRef(null);function w(e,t,n){let r=n.type.startsWith(`touch`);f.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),S.current=!1,s.current?.setOpen(!0,jp(Pp,n)),x.start(CR,()=>{S.current=!0})}function T(e){if(g)return;d.current=!0,vd(e),w(e.clientX,e.clientY,e.nativeEvent);let t=js(_.current);C.current?.abort();let n=new AbortController;C.current=n,t.addEventListener(`mouseup`,e=>{if(d.current=!1,!S.current)return;x.clear(),S.current=!1;let t=Fu(e);Q(u.current,t)||p&&t&&dR(t)===p||s.current?.setOpen(!1,jp(Gp,e))},{once:!0,signal:n.signal})}function E(){b.clear(),v.current=null}function D(e){if(g||(d.current=!1,e.touches.length!==1)){E();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};v.current=n,b.start(CR,()=>{w(n.x,n.y,e.nativeEvent)})}function O(e){if(e.touches.length!==1)E();else if(b.isStarted()&&v.current){let t=e.touches[0],n=Math.abs(t.clientX-v.current.x),r=Math.abs(t.clientY-v.current.y);(n>10||r>10)&&E()}}return y.useEffect(()=>()=>{C.current?.abort()},[]),y.useEffect(()=>{function e(e){if(g)return;let t=Fu(e);(Q(_.current,t)||Q(c.current,t)||Q(l.current,t))&&e.preventDefault()}return su(js(_.current),`contextmenu`,e)},[l,g,c]),Zs(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:T,onTouchStart:D,onTouchMove:O,onTouchEnd:E,onTouchCancel:E,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:id})}),TR=ML;function ER({...e}){return(0,G.jsx)(SR,{"data-slot":`context-menu`,...e})}function DR({className:e,...t}){return(0,G.jsx)(wR,{"data-slot":`context-menu-trigger`,className:X(`select-none`,e),...t})}function OR({className:e,align:t=`start`,alignOffset:n=4,side:r=`right`,sideOffset:i=0,...a}){return(0,G.jsx)(lL,{children:(0,G.jsx)(TR,{className:`isolate z-50 outline-none`,align:t,alignOffset:n,side:r,sideOffset:i,children:(0,G.jsx)(oL,{"data-slot":`context-menu-content`,className:X(`z-50 max-h-(--available-height) w-50 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-[10px] bg-popover p-1 text-xs text-popover-foreground shadow-[0_12px_40px_rgba(0,0,0,.3)] ring-1 ring-border duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...a})})})}function kR({...e}){return(0,G.jsx)(FI,{"data-slot":`context-menu-group`,...e})}function AR({className:e,inset:t,...n}){return(0,G.jsx)(II,{"data-slot":`context-menu-label`,"data-inset":t,className:X(`px-2 pt-1.5 pb-1 text-[11px] font-semibold text-faint data-inset:pl-7`,e),...n})}function jR({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(RI,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:X(`group/context-menu-item relative flex h-7 cursor-default items-center gap-1.5 rounded-md px-2 py-0 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function MR({className:e,...t}){return(0,G.jsx)(_R,{"data-slot":`context-menu-separator`,className:X(`my-1 h-px bg-border`,e),...t})}function NR({className:e,...t}){return(0,G.jsx)(`kbd`,{"data-slot":`context-menu-shortcut`,className:X(`ml-auto grid h-5 min-w-5 place-items-center rounded-[5px] bg-muted px-[5px] font-sans text-[11px] font-normal text-muted-foreground`,e),...t})}function PR({action:e,children:t,binding:n,chips:r,keyName:i,variant:a}){let o=n??e?.keys?.[0],s=r??(o?RF(o):[]);return(0,G.jsxs)(jR,{variant:a,disabled:!e||!Se(e),"aria-keyshortcuts":i,onClick:()=>e?.run(),children:[t??e?.label,s.length>0?(0,G.jsx)(`span`,{"aria-hidden":!0,className:`ml-auto flex gap-[3px]`,children:s.map((e,t)=>(0,G.jsx)(`kbd`,{className:`grid h-5 min-w-5 place-items-center rounded-[5px] bg-muted px-[5px] font-sans text-[11px] font-normal text-muted-foreground`,children:e},t))}):null]})}function FR({action:e}){return(0,G.jsx)(PR,{action:e,chips:[`⌫`],keyName:`Delete`,variant:`destructive`,children:`Delete`})}function IR({children:e}){return(0,G.jsx)(AR,{children:e})}function LR(e,t,n,r){let i=r?e.find(e=>e.ref===r.frame&&!e.hidden):void 0;if(r&&i&&RR(r.box,t))return{kind:`element`,frame:i,at:t};let a=vF(e,t,n);return a?{kind:`frame`,frame:a,at:t}:{kind:`canvas`,at:t}}function RR(e,{x:t,y:n}){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}var zR={frame:`w-55`,element:`w-[230px]`,canvas:`w-[210px]`};function BR({page:e,frames:t,viewport:n,layer:r,trigger:i}){let[a,o]=(0,y.useState)(null),s=e=>{let i=n.current,a=r.current;if(!i||!a)return null;let o=sN(i),[s,c]=o.invert(Vk(e,i)),{element:l}=bD.getState(),u=l?_F(a):null;return LR(t(),{x:s,y:c},o.k,l&&u?{frame:l.frame,box:u}:null)};return(0,G.jsxs)(ER,{onOpenChangeComplete:e=>{e||oI.setState({at:null,frame:null})},children:[(0,G.jsx)(DR,{render:i,onContextMenu:t=>{let n=t.nativeEvent.defaultPrevented?null:s(t.nativeEvent);if(!n)t.preventBaseUIHandler();else{if(n.kind===`frame`){let{frames:t,element:r}=bD.getState();(r||!t.includes(n.frame.ref))&&sD(bD,e,[n.frame.ref])}oI.setState({at:n.at,frame:n.kind===`canvas`?null:n.frame.ref}),o(n)}}}),(0,G.jsxs)(OR,{className:a?zR[a.kind]:void 0,children:[a?.kind===`frame`?(0,G.jsx)(HR,{}):null,a?.kind===`element`?(0,G.jsx)(WR,{noteable:!0}):null,a?.kind===`canvas`?(0,G.jsx)(KR,{}):null]})]})}var VR=[`frame.copyPng`,`frame.duplicate`,`frame.rename`,`frame.hide`,`frame.lock`,`frame.flipTheme`,`frame.delete`];function HR(){let[e,t,n,r,i,a,o]=Ce(VR);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(kR,{children:[(0,G.jsx)(PR,{action:e,children:`Copy as PNG`}),(0,G.jsx)(PR,{action:t,children:`Duplicate`}),(0,G.jsx)(PR,{action:n,children:`Rename`})]}),(0,G.jsx)(MR,{}),(0,G.jsxs)(kR,{children:[(0,G.jsx)(PR,{action:r,children:`Hide`}),(0,G.jsx)(PR,{action:i,children:i?.checked?.()?`Unlock`:`Lock`}),(0,G.jsx)(PR,{action:a})]}),(0,G.jsx)(MR,{}),(0,G.jsx)(FR,{action:o})]})}var UR=[`note.addHere`,`tool.note`,`element.up`,`view.zoomToSelection`,`frame.copyPng`];function WR({noteable:e}){let[t,n,r,i,a]=Ce(UR),o=xD(e=>e.element??null),s=o?NP(o.frame):null,c=o&&s?RP(s.elements,o.index)===null:!0;return(0,G.jsxs)(kR,{children:[(0,G.jsx)(IR,{children:`Element`}),e?(0,G.jsx)(PR,{action:t,binding:n?.keys?.[0],children:`Add a note here`}):null,(0,G.jsx)(PR,{action:r,children:c?`Select frame`:`Select parent`}),(0,G.jsx)(PR,{action:i,children:`Zoom to selection`}),(0,G.jsx)(MR,{}),(0,G.jsx)(PR,{action:a,children:`Copy frame as PNG`})]})}var GR=[`frame.pasteAt`,`frame.paste`,`frame.newAt`,`tool.frame`,`selection.all`,`view.zoomToFit`,`view.hideUi`];function KR(){let[e,t,n,r,i,a,o]=Ce(GR);return(0,G.jsxs)(kR,{children:[(0,G.jsx)(IR,{children:`Empty canvas`}),(0,G.jsx)(PR,{action:e,binding:t?.keys?.[0],children:`Paste here`}),(0,G.jsx)(PR,{action:n,binding:r?.keys?.[0],children:`New frame here`}),(0,G.jsx)(MR,{}),(0,G.jsx)(PR,{action:i,children:`Select all`}),(0,G.jsx)(PR,{action:a,children:`Zoom to fit`}),(0,G.jsx)(PR,{action:o,children:`Hide UI`})]})}function qR(e,t){return t&&e.some(e=>e.session===t)?t:e.length===1?e[0]?.session??``:``}function JR(e){if(e instanceof jl){if(e.code===`stale-address`)return`The frame changed since it was clicked. Click the element again.`;if(e.code===`unauthorized`)return`This tab cannot write. Open the board through frameboard serve.`;if(e.code===`notes-invalid`)return`This page's notes.json does not read. Fix it by hand and try again.`}return`The note did not save. Try again.`}function YR({listeners:e}){return(0,G.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5 font-normal text-muted-foreground`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-claim`}),e.length===0?`No session listening`:`${e.length} listening`]})}function XR({listeners:e,value:t,onChange:n,disabled:r}){let i=e.length===0;return(0,G.jsxs)(`label`,{className:`relative flex h-[26px] min-w-0 items-center gap-1.5 rounded-md bg-muted pr-6 pl-2 text-foreground has-[select:disabled]:opacity-60 has-[select:focus-visible]:ring-3 has-[select:focus-visible]:ring-ring/50`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`size-[7px] shrink-0 rounded-full bg-claim`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Send to`}),(0,G.jsxs)(`select`,{value:t,disabled:r||i,onChange:e=>n(e.target.value),className:`min-w-0 appearance-none truncate bg-transparent outline-none disabled:cursor-not-allowed`,children:[i?(0,G.jsx)(`option`,{value:``,children:`No session`}):null,!i&&e.length>1?(0,G.jsx)(`option`,{value:``,disabled:!0,children:`Pick a session`}):null,e.map(e=>(0,G.jsx)(`option`,{value:e.session,children:e.tag},e.session))]}),(0,G.jsx)(dt,{"aria-hidden":!0,className:`pointer-events-none absolute right-2 size-2.5 text-muted-foreground`})]})}function ZR({pick:e,onClose:t}){let n=Z(e=>e.listeners),r=Z(t=>t.claims[e.frame.ref]?.session),i=Z(e=>e.canWrite),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(()=>qR(n,r)),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(!1),p=n.some(e=>e.session===s)?s:qR(n,r),m=async n=>{if(a.trim()===``)u(`Write the note first`);else if(n===``)u(`Pick a session to send it to`);else{f(!0);try{await Ml(`/api/notes`,{frame:e.frame.ref,text:a.trim(),...e.element===null?{}:{element:e.element,renderedAt:e.renderedAt},...n===null?{}:{to:n}}),t()}catch(e){u(JR(e))}finally{f(!1)}}};return(0,G.jsx)(QR,{title:`New note on ${e.frame.name}`,listeners:n,onClose:t,children:(0,G.jsxs)(`form`,{className:`m-3 rounded-lg border border-border p-2`,onSubmit:e=>{e.preventDefault(),m(p)},children:[(0,G.jsx)(`textarea`,{"aria-label":`Note on ${e.frame.name}`,autoFocus:!0,value:a,disabled:!i,onChange:e=>{o(e.target.value),u(null)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&e.currentTarget.form?.requestSubmit()},rows:2,className:`block min-h-7 w-full resize-none bg-transparent text-foreground outline-none placeholder:text-faint disabled:cursor-not-allowed`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(XR,{listeners:n,value:p,onChange:e=>{c(e),u(null)},disabled:!i}),(0,G.jsx)($R,{variant:`ghost`,className:`ml-auto`,disabled:!i||d,onClick:()=>void m(null),children:`Save`}),(0,G.jsx)($R,{type:`submit`,variant:`primary`,disabled:!i||d||n.length===0,children:`Send`})]}),l?(0,G.jsx)(`p`,{role:`alert`,className:`mt-2 text-destructive`,children:l}):null]})})}function QR({title:e,listeners:t,onClose:n,children:r}){return(0,G.jsxs)(`section`,{"aria-label":e,"data-note-card":!0,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),n())},onPointerDown:e=>e.stopPropagation(),onWheel:e=>e.stopPropagation(),className:`pointer-events-auto w-[300px] overflow-hidden rounded-xl border border-border bg-card text-body text-card-foreground shadow-[0_12px_40px_rgba(0,0,0,.3)]`,children:[(0,G.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border px-3 py-2.5 font-semibold`,children:[(0,G.jsx)(`h2`,{className:`truncate`,children:e}),(0,G.jsx)(YR,{listeners:t})]}),r]})}function $R({variant:e,className:t,type:n=`button`,...r}){return(0,G.jsx)(`button`,{type:n,className:X(`flex h-[26px] shrink-0 items-center rounded-lg px-3 font-medium outline-none focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50`,e===`primary`?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-foreground hover:bg-accent`,t),...r})}function ez(e){return e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()).join(``)}var tz,nz=!1,rz=new Set;function iz(){return(0,y.useSyncExternalStore)(az,()=>tz)}function az(e){return rz.add(e),nz||(nz=!0,fetch(`/api/author`).then(e=>e.json()).then(e=>e.ok?e.data.name:null).catch(()=>null).then(e=>{tz=e;for(let e of rz)e()})),()=>{rz.delete(e)}}function oz({notes:e,page:t,onClose:n}){let r=Z(e=>e.listeners),i=Z(n=>t?n.claims[`${t}/${e[0]?.frame}`]?.session:void 0),a=Z(e=>e.canWrite),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(()=>qR(r,i)),[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(!1),m=e[0];if(!m)return null;let h=r.some(e=>e.session===c)?c:qR(r,i),g=async(e,t)=>{p(!0);try{await e(),t?.()}catch(e){d(JR(e))}finally{p(!1)}},_=()=>{let e=o.trim();e===``&&h===``?d(r.length>1?`Pick a session to send it to`:`Write a reply first`):e===``?g(()=>Ml(`/api/notes/${m.id}/send`,{to:h})):g(()=>Ml(`/api/notes/${m.id}/replies`,{text:e,...h===``?{}:{to:h}}),()=>s(``))};return(0,G.jsxs)(QR,{title:`Note ${m.number??``}`.trim(),listeners:r,onClose:n,children:[(0,G.jsx)(`ol`,{"aria-label":`Messages`,children:e.map(e=>(0,G.jsx)(sz,{note:e},e.id))}),(0,G.jsxs)(`form`,{className:`mx-3 mt-1.5 mb-3 rounded-lg border border-border p-2`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,G.jsx)(`textarea`,{"aria-label":`Reply`,placeholder:`Reply, or hand it on…`,value:o,disabled:!a,onChange:e=>{s(e.target.value),d(null)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&e.currentTarget.form?.requestSubmit()},rows:1,className:`block min-h-7 w-full resize-none bg-transparent text-foreground outline-none placeholder:text-faint disabled:cursor-not-allowed`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(XR,{listeners:r,value:h,onChange:e=>{l(e),d(null)},disabled:!a}),(0,G.jsx)($R,{variant:`ghost`,className:`ml-auto`,disabled:!a||f,onClick:()=>void g(()=>Ml(`/api/notes/${m.id}/done`,{}),n),children:`Done`}),(0,G.jsx)($R,{type:`submit`,variant:`primary`,disabled:!a||f,children:`Send`})]}),u?(0,G.jsx)(`p`,{role:`alert`,className:`mt-2 text-destructive`,children:u}):null]})]})}function sz({note:e}){let t=iz(),n=e.from===`agent`;return(0,G.jsxs)(`li`,{className:`flex gap-2.5 px-3 py-2.5`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:X(`grid size-[22px] flex-none place-items-center rounded-full text-[10px] font-bold`,n?`bg-claim/25 text-claim`:`bg-foreground text-card`),children:n?`C`:ez(e.author??t??``)||`Y`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`b`,{className:`font-semibold`,children:n?`claude`:`You`}),(0,G.jsx)(`time`,{dateTime:e.createdAt,className:`ml-1.5 text-faint`,children:cz(e.createdAt)}),(0,G.jsx)(`p`,{className:`mt-0.5 leading-[1.45] break-words whitespace-pre-wrap`,children:e.text})]})]})}function cz(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.getHours()%12||12}:${String(t.getMinutes()).padStart(2,`0`)}`}function lz({page:e,frames:t,container:n}){let r=Z(t=>t.notes[e]),i=aD(e=>e.mode===`play`),a=EP(e=>e.open);if(gz(n),hz(a!==null),i)return null;let o=(r??[]).filter(e=>e.thread===null&&e.state!==`done`),s=new Map(t.map(e=>[e.name,e])),c=e=>{let t=s.get(e.frame);return t?mz(t,e.element,n):null},l=Math.max(0,...(r??[]).map(e=>e.number??0))+1,u=a?.kind===`thread`&&a.page===e?(r??[]).filter(e=>e.id===a.id||e.thread===a.id):null,d=u?.[0],f=d?c(d):null;return(0,G.jsxs)(G.Fragment,{children:[o.map(t=>{let n=c(t);return!n||t.number===null?null:(0,G.jsx)(uz,{number:t.number,at:n,active:a?.kind===`thread`&&a.id===t.id,label:`Note ${t.number} on ${t.frame}`,onOpen:()=>TP.setState({open:{kind:`thread`,page:e,id:t.id}})},t.id)}),a?.kind===`new`&&t.some(e=>e.ref===a.pick.frame.ref)?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(uz,{number:l,at:a.pick.at,active:!0}),(0,G.jsx)(pz,{at:a.pick.at,children:(0,G.jsx)(ZR,{pick:a.pick,onClose:DP},a.pick.frame.ref)})]}):null,u&&f?(0,G.jsx)(pz,{at:f,children:(0,G.jsx)(oz,{notes:u,page:e,onClose:DP})}):null]})}function uz({number:e,at:t,active:n,label:r,onOpen:i}){let a=X(`pointer-events-auto absolute grid size-[22px] place-items-center rounded-[11px_11px_11px_2px] bg-note text-label font-semibold text-[#1a1a1a] shadow-[0_2px_6px_rgba(0,0,0,.25)] outline-none [transform:translate(-50%,-50%)_scale(calc(1/var(--zoom,1)))] focus-visible:ring-3 focus-visible:ring-ring/50`,n&&`shadow-[0_0_0_3px_color-mix(in_srgb,var(--note)_35%,transparent),0_2px_6px_rgba(0,0,0,.25)]`),o={left:t.x,top:t.y};return i?(0,G.jsx)(`button`,{type:`button`,"data-note-marker":!0,"aria-label":r,"aria-expanded":n,onPointerDown:e=>e.stopPropagation(),onClick:i,className:a,style:o,children:e}):(0,G.jsx)(`span`,{"aria-hidden":!0,className:a,style:o,children:e})}var dz={x:21,y:-25},fz=12;function pz({at:e,children:t}){let n=(0,y.useRef)(null),[r,i]=(0,y.useState)({flip:!1,y:0});return(0,y.useLayoutEffect)(()=>{let e=n.current,t=e?.closest(`[data-canvas]`);if(!e||!t)return;let a=t.getBoundingClientRect(),o=e.getBoundingClientRect(),s=r.flip?o.right+o.width+2*dz.x:o.right,c=o.top-r.y,l={flip:s>a.right-fz,y:c<a.top+fz?a.top+fz-c:Math.min(0,a.bottom-fz-(c+o.height))};(l.flip!==r.flip||Math.abs(l.y-r.y)>.5)&&i(l)},[e.x,e.y,r]),(0,G.jsx)(`div`,{className:`absolute origin-top-left [transform:scale(calc(1/var(--zoom,1)))]`,style:{left:e.x,top:e.y},children:(0,G.jsx)(`div`,{ref:n,className:`absolute`,style:{top:dz.y+r.y,...r.flip?{right:dz.x}:{left:dz.x}},children:t})})}function mz(e,t,n){let{x:r,y:i,width:a}=e.box,o=t===null?null:n?.querySelector(`[data-frame="${CSS.escape(e.ref)}"] iframe`)?.contentDocument,s=o&&t!==null?BN(o,t):null;if(!s)return{x:r+a,y:i};let c=s.getBoundingClientRect();return{x:r+Math.min(c.right,a),y:i+Math.max(c.top,0)}}function hz(e){(0,y.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&DP()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function gz(e){let[,t]=(0,y.useState)(0);(0,y.useEffect)(()=>{if(!e)return;let n=()=>t(e=>e+1);return e.addEventListener(`load`,n,!0),()=>e.removeEventListener(`load`,n,!0)},[e])}var _z=[.02,4],vz=64,yz=150,bz=400,xz=new Map;function Sz({page:e,reloads:t,findings:n,claims:r,focus:i,onFocused:a}){let o=(0,y.useRef)(null),s=(0,y.useRef)(null),c=(0,y.useRef)(null),l=(0,y.useRef)(null),[u,d]=(0,y.useState)(null),f=(0,y.useRef)(null),p=(0,y.useRef)(0),m=aD(e=>e.mode===`play`),h=aD(e=>e.tool===`hand`),g=aD(e=>e.tool===`note`),_=aD(e=>e.tool===`frame`);kP();let v=jN(e=>e.unseen),[b,x]=(0,y.useState)(null),S=(0,y.useMemo)(()=>e.frames.filter(e=>!e.hidden),[e.frames]),C=(0,y.useRef)(S);(0,y.useLayoutEffect)(()=>{C.current=S},[S]),HP(e.ref),dF(e.ref,S),cI(e.ref,e.frames,e=>s.current?.querySelector(`[data-frame="${CSS.escape(e)}"] iframe`)?.dataset.renderedAt??null),(0,y.useLayoutEffect)(()=>{let t=o.current,n=s.current;if(!t||!n)return;let r=zk(t),i,a=!1,c=e=>x({view:e,size:Ez(t)}),u=gN().scaleExtent(_z).filter(e=>{if(e.type===`wheel`||e.type.startsWith(`touch`))return!0;let{button:t,ctrlKey:n}=e;if(n)return!1;let{mode:r,tool:i}=iD.getState();return t===1||t===0&&(i===`hand`||r===`play`)}).on(`zoom`,({transform:{x:t,y:r,k:o}})=>{clearTimeout(i);for(let e of[n,l.current])e&&(e.style.transform=`translate(${t}px, ${r}px) scale(${o})`,e.style.setProperty(`--zoom`,String(o)));xz.set(e.ref,{x:t,y:r,k:o}),jD(o),a||AD()}).on(`end`,({transform:{x:e,y:t,k:n}})=>{clearTimeout(i),i=setTimeout(()=>c({x:e,y:t,k:n}),yz)});r.call(u).on(`dblclick.zoom`,null).on(`wheel.zoom`,e=>{e.preventDefault();let n=sN(t).k,i=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:1;e.ctrlKey||e.metaKey?u.scaleBy(r,2**(-e.deltaY*i*.01),Vk(e,t)):u.translateBy(r,-e.deltaX*i/n,-e.deltaY*i/n)},{passive:!1});let d=0,p=({x:e,y:t,k:n})=>{a=!0;try{u.transform(r,oN.translate(e,t).scale(n))}finally{a=!1}},m=xz.get(e.ref)??Dz(C.current,Ez(t));p(m),clearTimeout(i),c(m);let h=new ResizeObserver(()=>c(xz.get(e.ref)??m));h.observe(t),f.current=e=>{if(cancelAnimationFrame(d),matchMedia(`(prefers-reduced-motion: reduce)`).matches){p(e);return}let n=sN(t),r=performance.now(),i=t=>{let a=Math.min(1,(t-r)/bz);if(a===1){p(e);return}let o=a<.5?4*a**3:1-(-2*a+2)**3/2;p({x:n.x+(e.x-n.x)*o,y:n.y+(e.y-n.y)*o,k:n.k*(e.k/n.k)**o}),d=requestAnimationFrame(i)};d=requestAnimationFrame(i)};let g=()=>AD();t.addEventListener(`pointerdown`,g,{capture:!0});let _=kD({zoomBy:e=>u.scaleBy(r,e),zoomTo:e=>u.scaleTo(r,e),fit:()=>{AD(),f.current?.(Dz(C.current,Ez(t)))},fitTo:e=>{AD(),f.current?.(Dz(e.map(e=>({box:e})),Ez(t)))},panBy:(e,n)=>{let i=sN(t).k;u.translateBy(r,-e/i,-n/i)},centerOn:e=>f.current?.(Tz(e,sN(t).k,Ez(t)))},e.ref);return()=>{t.removeEventListener(`pointerdown`,g,{capture:!0}),_(),clearTimeout(i),cancelAnimationFrame(d),f.current=null,h.disconnect(),r.on(`.zoom`,null)}},[e.ref]),(0,y.useEffect)(()=>{let t=fD(bD,e.ref,yl,iD),n=zE(yl),r=ZP(bD,yl,MN,e=>Ml(`/api/selection`,e));return()=>{r(),n(),t()}},[e.ref]),(0,y.useEffect)(()=>{let t=o.current,n=s.current,r=c.current;if(t&&n&&r)return AF(r,{viewport:t,layer:n,page:e.ref,frames:()=>C.current})},[e.ref,m]),(0,y.useEffect)(()=>{let e=S.find(e=>e.ref===i),t=o.current;e&&t&&f.current&&(f.current(Dz([e],Ez(t))),a?.())},[i,S,a]);let w=t=>{let n=o.current;if(g||h||_||!n||!u)return;let[r,i]=sN(n).invert(Vk(t,n)),a=++p.current;XP(u,S,{x:r,y:i},IP).then(t=>{t&&a===p.current&&cD(bD,e.ref,t)})},T=(0,y.useMemo)(()=>b?wP(S,b.view,b.size):null,[S,b]);return IN((0,y.useMemo)(()=>b?{frames:S,...b}:null,[S,b])),(0,G.jsxs)(`div`,{ref:o,"data-canvas":!0,className:X(`relative size-full touch-none overflow-hidden bg-background`,h&&!m&&`cursor-grab active:cursor-grabbing`,(g||_)&&!m&&`cursor-crosshair`),children:[(0,G.jsx)(`div`,{ref:e=>{s.current=e,d(e)},"data-layer":!0,className:`absolute top-0 left-0 origin-top-left`,children:e.layoutError?null:(0,G.jsxs)(G.Fragment,{children:[S.map(e=>(0,G.jsx)(nF,{frame:e,live:T?.has(e.ref)??!1,version:t[e.ref]??0,findings:n?.[e.ref],claim:r?.[e.ref],unseen:e.ref in v},e.ref)),(0,G.jsx)(oP,{frames:S}),(0,G.jsx)(WP,{frames:S,container:u}),(0,G.jsx)(pP,{frames:S,container:u}),(0,G.jsx)(bP,{page:e.ref,frames:S})]})}),m?null:(0,G.jsx)(BR,{page:e.ref,frames:()=>C.current,viewport:o,layer:s,trigger:(0,G.jsx)(`div`,{ref:c,"data-hit-layer":!0,className:`absolute inset-0`,onClickCapture:t=>{let n=o.current;if(!(g||_)||!n||!u)return;t.stopPropagation();let[r,i]=sN(n).invert(Vk(t.nativeEvent,n));if(_){nI({x:r,y:i},{page:e.ref,frames:e.frames});return}let a=qP(u,S,{x:r,y:i});a?TP.setState({open:{kind:`new`,pick:a}}):DP()},onClick:e=>{e.metaKey&&w(e.nativeEvent)},onDoubleClick:e=>w(e.nativeEvent)})}),(0,G.jsx)(`div`,{ref:l,"data-notes-layer":!0,className:`pointer-events-none absolute top-0 left-0 origin-top-left`,children:(0,G.jsx)(lz,{page:e.ref,frames:S,container:u})}),(0,G.jsx)(xP,{frames:S}),e.layoutError?(0,G.jsx)(Cz,{error:e.layoutError}):S.length===0?(0,G.jsx)(wz,{}):null]})}function Cz({error:e}){return(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center p-6`,children:(0,G.jsxs)(`div`,{role:`alert`,className:`max-w-md rounded-lg border border-border bg-card p-4 text-body text-card-foreground`,children:[(0,G.jsx)(`p`,{className:`text-panel`,children:`This page's layout does not read`}),(0,G.jsx)(`p`,{className:`mt-1 break-all text-muted-foreground`,children:e.path}),(0,G.jsx)(`p`,{className:`mt-2`,children:e.message})]})})}function wz(){return(0,G.jsxs)(`div`,{role:`status`,className:`pointer-events-none absolute top-1/2 left-1/2 w-105 max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-[55%] text-center text-body leading-[1.6] text-muted-foreground`,children:[(0,G.jsx)(`div`,{"aria-hidden":!0,className:`mx-auto mb-3.5 h-12 w-16 rounded-lg border-[1.5px] border-dashed border-faint`}),(0,G.jsx)(`p`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`This page has no frames`}),(0,G.jsxs)(`p`,{children:[`Pick the Frame tool`,` `,(0,G.jsx)(`kbd`,{className:`rounded-[5px] bg-muted px-1.5 py-0.5 font-mono text-label font-normal text-foreground`,children:`F`}),` `,`and click on the canvas,`,(0,G.jsx)(`br`,{}),`or ask your agent to draw one.`]})]})}function Tz(e,t,n){return e.width*t>n.width-128||e.height*t>n.height-128?Dz([{box:e}],n):{x:n.width/2-(e.x+e.width/2)*t,y:n.height/2-(e.y+e.height/2)*t,k:t}}function Ez(e){return{width:e.clientWidth,height:e.clientHeight}}function Dz(e,t){if(e.length===0||t.width===0||t.height===0)return{x:vz,y:vz,k:1};let n=Math.min(...e.map(({box:e})=>e.x)),r=Math.min(...e.map(({box:e})=>e.y)),i=Math.max(...e.map(({box:e})=>e.x+e.width)),a=Math.max(...e.map(({box:e})=>e.y+e.height)),o=Math.min((t.width-128)/(i-n),(t.height-128)/(a-r),1),s=Math.max(_z[0],o);return{x:(t.width-(i-n)*s)/2-n*s,y:(t.height-(a-r)*s)/2-r*s,k:s}}function Oz(e=AN){let{unseen:t,cursor:n}=e.getState();return(n===null?void 0:t[n])??TN(t)[0]??null}function kz(e,t=F){let[n=``,r=``]=e.split(`/`),i=z(n,r);decodeURIComponent(location.pathname)!==decodeURIComponent(i)&&t(i),yl.setState({focus:e}),uP(e)}function Az(e=AN,t=F){(0,y.useEffect)(()=>{let n=()=>Object.keys(e.getState().unseen).length>0,r=be([{id:`changes.show`,label:`Show change`,group:`changes`,run:()=>{let n=Oz(e);n&&(CN(e,n.frame),kz(n.frame,t))},enabled:n,command:{label:`Show the agent change`,icon:Bn}},{id:`changes.next`,label:`Next change`,group:`changes`,keys:[`BracketRight`],run:()=>{let n=EN(e.getState().unseen,Oz(e)?.frame??null);n&&(CN(e,n.frame),kz(n.frame,t))},enabled:n,command:{label:`Next agent change`,icon:st}}]),i=e.subscribe(xe);return()=>{i(),r()}},[e,t])}function jz(e,t,n){let r=TN(e),i=r.length;if(i<=1){let e=t.author?.agent??null,r=t.frame.split(`/`).at(-1)??t.frame,i=t.whole?1:Math.max(t.elements.length,1),a=`${i} ${i===1?`change`:`changes`}`;return{initial:Nz(e),title:e?`${Mz(e)} updated ${r}`:`${r} changed`,detail:n?`${a}, glowing on the frame`:a,show:!n,next:!1,width:n?300:340}}let a=new Set(r.map(e=>e.author?.agent??null)),[o]=a,s=a.size===1&&o?o:null,c=new Set(r.map(e=>e.frame.split(`/`).slice(0,2).join(`/`))).size,l=r.findIndex(e=>e.id===t.id)+1;return{initial:Nz(s),title:s?`${Mz(s)} changed ${i} frames`:`${i} frames changed`,detail:`on ${c} ${c===1?`page`:`pages`} · ${l} of ${i}`,show:!0,next:!0,width:380}}function Mz(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function Nz(e){return e?e.charAt(0).toUpperCase():null}var Pz=5e3,Fz=R_();function Iz({store:e=AN}){return(0,G.jsxs)(D_,{toastManager:Fz,children:[(0,G.jsx)(Lz,{store:e}),(0,G.jsx)(k_,{className:`absolute right-4 bottom-[84px] z-20 w-auto`,children:(0,G.jsx)(Rz,{})})]})}function Lz({store:e}){return(0,y.useEffect)(()=>{let t=null,n,r=()=>{let r=Oz(e);if(r){clearTimeout(n),n=void 0;let i=jz(e.getState().unseen,r,r.frame in cP.getState().glowing);t===null?t=Fz.add({timeout:0,data:i,onClose:()=>{t=null}}):Fz.update(t,{data:i})}else t!==null&&n===void 0&&(n=setTimeout(()=>{n=void 0,t!==null&&Fz.close(t)},Pz))};r();let i=e.subscribe(r),a=cP.subscribe(r);return()=>{i(),a(),clearTimeout(n),t!==null&&Fz.close(t)}},[e]),null}function Rz(){let{toasts:e}=z_(),[t,n]=Ce([`changes.show`,`changes.next`]);return e.flatMap(e=>{let r=e.data;return r?(0,G.jsx)(A_,{toast:e,"data-change-toast":!0,style:{width:r.width},children:(0,G.jsxs)(j_,{className:`items-center`,children:[r.initial?(0,G.jsx)(`span`,{"aria-hidden":!0,className:`font-bold text-claim`,children:r.initial}):null,(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,G.jsx)(M_,{children:r.title}),(0,G.jsx)(N_,{children:r.detail})]}),r.show?(0,G.jsx)(`button`,{type:`button`,onClick:()=>t?.run(),className:X(zz,`bg-[color-mix(in_srgb,var(--claim)_22%,transparent)] text-claim`),children:`Show`}):null,r.next?(0,G.jsx)(`button`,{type:`button`,"aria-keyshortcuts":`]`,onClick:()=>n?.run(),className:X(zz,`bg-secondary text-foreground`),children:`Next ]`}):null]})},e.id):[]})}var zz=`ml-2 shrink-0 rounded-md px-2 py-[3px] font-medium whitespace-nowrap outline-none hover:brightness-95 focus-visible:ring-2 focus-visible:ring-ring/50`,Bz=y.createContext(void 0);function Vz(e){let t=y.useContext(Bz);if(t===void 0&&!e)throw Error(Ds(72));return t}var Hz={...Eh,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,appliedTriggerProps:(e,t)=>t?e.activeTriggerProps:void 0,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Uz=class extends au{constructor(e,t,n){let r=new _h;super(Wz(e,r,t,n),Gz(r),Hz)}setOpen=(e,t)=>{dh(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,jp(Pp,e))}};function Wz(e,t,n,r=!1){return{...bh(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function Gz(e){return{popupRef:y.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var Kz=Yl(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=ah((e,t)=>new Uz({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),h=!t&&m,g=p.useState(`activeTriggerId`),_=p.useState(`mounted`),v=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),ph(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:b,transitionStatus:x}=mh(h,p),S=p.useState(`isInstantPhase`),C=p.useState(`instantType`),w=p.useState(`lastOpenChangeReason`),T=y.useRef(null);Y(()=>{m&&t&&p.setOpen(!1,jp(qp))},[m,t,p]),Y(()=>{x===`ending`&&w===`none`||x!==`ending`&&S?(C!==`delay`&&(T.current=C),p.set(`instantType`,`delay`)):T.current!==null&&(p.set(`instantType`,T.current),T.current=null)},[x,S,w,C,p]),Y(()=>{h&&(g??p.set(`payload`,void 0))},[p,g,h]),y.useImperativeHandle(o,()=>({unmount:b,close:()=>p.setOpen(!1,jp(Xp))}),[b,p]);let E=h||_||!t&&a!==`none`;return(0,G.jsxs)(Bz.Provider,{value:p,children:[l&&(0,G.jsx)(oh,{handle:l,store:p}),E&&(0,G.jsx)(qz,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function qz({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=$m(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=Xm(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=y.useMemo(()=>ps(a.reference,i.reference),[a.reference,i.reference]);return hh(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??qs}),null}var Jz=y.createContext(void 0);function Yz(){return y.useContext(Jz)}var Xz=`data-base-ui-tooltip-trigger`;function Zz(e){let t=Fu(e);return q(t)?t:null}var Qz=Xl(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d,...f}=e,p=Vz(!0),m=Dh(a)??p;if(!m)throw Error(Ds(82));let h=OI(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),b=y.useRef(null),x=u??0,{registerTrigger:S,isMountedByThisTrigger:C}=fh(h,b,m,{payload:o,closeOnClick:l,closeDelay:x}),w=Yz(),{activeIdRef:T,delayRef:E,isInstantPhase:D,hasProvider:O}=hm(v,{open:_}),k=Ph(v);m.useSyncedValue(`isInstantPhase`,D);let A=m.useState(`disabled`),j=s??A,M=am(j),N=m.useState(`trackCursorAxis`),P=m.useState(`disableHoverablePopup`),F=y.useRef(!1),I=hu(),L=y.useRef(void 0);function R(){return O&&T.current!=null?0:c??w??600}function z(e){let t=b.current;if(!t||!e)return!1;let n=Pu(e,`[${Xz}]`);return n!==null&&n!==t&&Q(t,n)}function B(e){let t=z(e);return F.current=t,t&&(k.openChangeTimeout.clear(),k.restTimeout.clear(),k.restTimeoutPending=!1,I.clear()),t}let ee=Lh(v,{enabled:!j,mouseOnly:!0,move:!1,handleClose:!P&&N!==`both`?$h():null,restMs:R,delay(){return u==null&&O?{close:cm(E.current,`close`)}:{close:x}},triggerElementRef:b,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!F.current}}),te=kh(v,{enabled:!j}).reference,ne=e=>{let t=F.current,n=Zz(e),r=B(n),i=b.current,a=i&&n&&Q(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`)m.setOpen(!1,jp(Fp,e));else if(t&&!r&&a&&!M.current&&!m.select(`open`)&&i&&Sd(L.current)){let t=()=>{!F.current&&!M.current&&!m.select(`open`)&&m.setOpen(!0,jp(Fp,e,i))},n=R();n===0?(I.clear(),t()):I.start(n,t)}},re=m.useState(`appliedTriggerProps`,C||N!==`none`);return Zs(`button`,e,{state:{open:_},ref:[t,S,b],props:[ee,te,re,{onMouseOver(e){ne(e.nativeEvent)},onFocus(e){z(Zz(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){F.current=!1,I.clear(),L.current=void 0},onPointerEnter(e){L.current=e.pointerType},onPointerDown(e){L.current=e.pointerType,m.set(`closeOnClick`,l),l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},id:h,[sd]:j?``:void 0,[Xz]:j?void 0:``},f],stateAttributesMapping:rd})}),$z=y.createContext(void 0);function eB(){let e=y.useContext($z);if(e===void 0)throw Error(Ds(70));return e}var tB=y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Vz().useState(`mounted`)||n?(0,G.jsx)($z.Provider,{value:n,children:(0,G.jsx)(rm,{ref:t,...r})}):null}),nB=y.createContext(void 0);function rB(){let e=y.useContext(nB);if(e===void 0)throw Error(Ds(71));return e}var iB=y.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=np,style:g,..._}=e,v=Vz(),b=eB(),x=v.useState(`open`),S=v.useState(`mounted`),C=v.useState(`trackCursorAxis`),w=v.useState(`disableHoverablePopup`),T=v.useState(`floatingRootContext`),E=v.useState(`instantType`),D=v.useState(`transitionStatus`),O=y_({anchor:i,positionMethod:a,floatingRootContext:T,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,adaptiveOrigin:v.useState(`adaptiveOrigin`)}),k=C_(e,y.useMemo(()=>({open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:C===`none`?E:`tracking-cursor`}),[x,O.side,O.align,O.anchorHidden,C,E]),{styles:O.positionerStyles,transitionStatus:D,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!S,inert:!x||C===`both`||w});return(0,G.jsx)(nB.Provider,{value:O,children:k})}),aB=y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Vz(),{side:s,align:c}=rB(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);Yf({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Fh(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return Zs(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[rh,f,S_(d),a],stateAttributesMapping:od})}),oB=y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Vz(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=rB();return Zs(`div`,e,{state:{open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)},ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:ad})}),sB=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=y.useMemo(()=>({open:t,close:n}),[t,n]);return(0,G.jsx)(Jz.Provider,{value:t,children:(0,G.jsx)(mm,{delay:i,timeoutMs:r,children:e.children})})};function cB({delay:e=0,...t}){return(0,G.jsx)(sB,{"data-slot":`tooltip-provider`,delay:e,...t})}function lB({...e}){return(0,G.jsx)(Kz,{"data-slot":`tooltip`,...e})}function uB({...e}){return(0,G.jsx)(Qz,{"data-slot":`tooltip-trigger`,...e})}function dB({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,children:a,...o}){return(0,G.jsx)(tB,{children:(0,G.jsx)(iB,{align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,G.jsxs)(aB,{"data-slot":`tooltip-content`,className:X(`z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...o,children:[a,(0,G.jsx)(oB,{className:`z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`})]})})})}function fB({label:e,keys:t,children:n,side:r=`top`}){let i=t?.[0];return(0,G.jsxs)(lB,{children:[(0,G.jsx)(uB,{render:n}),(0,G.jsx)(dB,{side:r,sideOffset:6,className:`rounded-md px-2 py-[5px] text-[11px]`,children:i?`${e} ${LF(i)}`:e})]})}function pB({...e}){return(0,G.jsx)(rR,{"data-slot":`dropdown-menu`,...e})}function mB({...e}){return(0,G.jsx)(mR,{"data-slot":`dropdown-menu-trigger`,...e})}function hB({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){return(0,G.jsx)(lL,{children:(0,G.jsx)(ML,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,G.jsx)(oL,{"data-slot":`dropdown-menu-content`,className:X(`z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95`,i),...a})})})}function gB({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(RI,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:X(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function _B({...e}){return(0,G.jsx)(aR,{"data-slot":`dropdown-menu-sub`,...e})}function vB({className:e,inset:t,children:n,...r}){return(0,G.jsxs)(xR,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:X(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,G.jsx)(pt,{className:`ml-auto`})]})}function yB({align:e=`start`,alignOffset:t=-3,side:n=`right`,sideOffset:r=0,className:i,...a}){return(0,G.jsx)(hB,{"data-slot":`dropdown-menu-sub-content`,className:X(`w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,i),align:e,alignOffset:t,side:n,sideOffset:r,...a})}function bB({...e}){return(0,G.jsx)(IL,{"data-slot":`dropdown-menu-radio-group`,...e})}function xB({className:e,children:t,inset:n,...r}){return(0,G.jsxs)(BL,{"data-slot":`dropdown-menu-radio-item`,"data-inset":n,className:X(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[(0,G.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-radio-item-indicator`,children:(0,G.jsx)(VL,{children:(0,G.jsx)(lt,{})})}),t]})}function SB({className:e,...t}){return(0,G.jsx)(_R,{"data-slot":`dropdown-menu-separator`,className:X(`-mx-1 my-1 h-px bg-border`,e),...t})}var CB={name:`frameboard`,version:`0.6.0`,description:`A local design board that coding agents draw on as plain HTML files`,keywords:[`design`,`board`,`canvas`,`html`,`coding-agent`,`claude-code`,`cli`],homepage:`https://github.com/erclx/frameboard#readme`,bugs:{url:`https://github.com/erclx/frameboard/issues`},repository:{type:`git`,url:`git+https://github.com/erclx/frameboard.git`},license:`MIT`,type:`module`,bin:{frameboard:`dist/cli.js`},files:[`dist`],engines:{node:`>=22`},scripts:{typecheck:`tsc --noEmit`,build:`vite build && rolldown -c rolldown.config.ts && bun scripts/copy-faces.ts`,dev:`WORKTREE_PORT_OFFSET=$(bash scripts/worktree-port.sh) && export WORKTREE_PORT_OFFSET && vite`,preview:"node dist/cli.js serve --root test/fixtures/boards/basic --no-open --port ${PREVIEW_PORT:-4173}",test:`vitest`,"test:run":`vitest run --reporter=verbose`,"test:ui":`vitest --ui`,"test:coverage":`vitest run --coverage --project node`,"test:e2e":`WORKTREE_PORT_OFFSET=$(bash scripts/worktree-port.sh) && export WORKTREE_PORT_OFFSET && playwright test`,"test:e2e:changed":`WORKTREE_PORT_OFFSET=$(bash scripts/worktree-port.sh) && export WORKTREE_PORT_OFFSET && playwright test --only-changed`,"test:e2e:ui":`WORKTREE_PORT_OFFSET=$(bash scripts/worktree-port.sh) && export WORKTREE_PORT_OFFSET && playwright test --ui`,"test:e2e:report":`playwright show-report`,"check:full":`bun scripts/verify.ts && bun run test:e2e`,"measure:canvas":`bun run build && playwright test -c e2e/perf/playwright.config.ts`,"smoke:prod":`bun e2e/screenshot.ts --check-console-clean --require-base-url`,prepare:`husky`,"design:sync":`bun scripts/design-sync.ts`,check:`bun scripts/verify.ts`,"check:format":`oxfmt --check .`,format:`oxfmt .`,lint:`oxlint --max-warnings 0`,"lint:fix":`oxlint --fix --max-warnings 0`,screenshot:`PREVIEW_PORT=$(bash scripts/worktree-port.sh 4173) && export PREVIEW_PORT && bash scripts/screenshot.sh`,"screenshot:compare":`bun run build && bun e2e/compare.ts`,"readme-screenshot":`PREVIEW_PORT=$(bash scripts/worktree-port.sh 4173) && export PREVIEW_PORT && bash scripts/readme-screenshot.sh`},devDependencies:{"@atlaskit/pragmatic-drag-and-drop":`4.0.0`,"@atlaskit/pragmatic-drag-and-drop-hitbox":`3.0.0`,"@base-ui/react":`^1.9.0`,"@bramus/specificity":`^2.4.3`,"@commitlint/cli":`^21.2.3`,"@commitlint/config-conventional":`^21.2.3`,"@fontsource-variable/caveat":`^5.3.0`,"@fontsource-variable/geist":`^5.3.0`,"@fontsource-variable/geist-mono":`^5.3.0`,"@hono/node-server":`^2.1.5`,"@playwright/test":`^1.64.1`,"@tailwindcss/vite":`^4.3.3`,"@testing-library/jest-dom":`^7.0.1`,"@testing-library/react":`^16.3.3`,"@testing-library/user-event":`^14.6.8`,"@types/d3-drag":`^3.0.7`,"@types/d3-selection":`^3.0.12`,"@types/d3-zoom":`^3.0.9`,"@types/jsdom":`^30.0.0`,"@types/node":`^26.6.5`,"@types/react":`^19.3.0`,"@types/react-dom":`^19.3.0`,"@types/ws":`^8.18.2`,"@vitejs/plugin-react":`^6.1.2`,"@vitest/browser-playwright":`^5.0.4`,"@vitest/coverage-v8":`^5`,"@vitest/ui":`^5`,chokidar:`^5.0.0`,"class-variance-authority":`^0.7.1`,cmdk:`^1.1.1`,cn:`^0.4.0`,commander:`^15.0.0`,"css-select":`^7.0.0`,"d3-drag":`3.0.0`,"d3-selection":`^3.0.0`,"d3-zoom":`^3.0.0`,"eslint-plugin-check-file":`^3.3.2`,"eslint-plugin-simple-import-sort":`^14.0.0`,"fast-check":`^4.10.2`,hono:`^4.13.13`,husky:`^9.1.7`,jsdom:`^30.1.2`,"lucide-react":`^1.57.0`,oxfmt:`0.73.0`,oxlint:`1.88.0`,parse5:`^8.0.1`,"parse5-htmlparser2-tree-adapter":`^8.0.1`,playwright:`^1.64.1`,postcss:`^8.5.6`,react:`^19.3.1`,"react-dom":`^19.3.1`,"react-resizable-panels":`^4.14.5`,rolldown:`^1.2.14`,shadcn:`^4.21.5`,tailwindcss:`^4.3.3`,tinykeys:`^4.0.1`,"tw-animate-css":`^1.4.0`,typescript:`^7`,vite:`^8.3.4`,vitest:`^5`,wouter:`^3.13.0`,ws:`^8.22.0`,zod:`^4.6.7`,zustand:`^5.0.15`},dependencies:{"playwright-core":`1.64.1`}};function wB({className:e,...t}){return(0,G.jsx)(hB,{className:X(`w-60 rounded-[10px] p-1 text-xs shadow-[0_12px_40px_rgba(0,0,0,.3)] ring-border`,e),...t})}function TB({action:e,label:t,keys:n,children:r}){let i=(e?.keys??n)?.[0];return(0,G.jsxs)(gB,{disabled:!e||!Se(e),onClick:()=>e?.run(),className:EB,children:[r??e?.label??t,i?(0,G.jsx)(DB,{children:LF(i)}):null]})}var EB=`h-7 rounded-md px-2 py-0 text-xs`;function DB({children:e}){return(0,G.jsx)(`kbd`,{className:`ml-auto grid h-5 min-w-5 place-items-center rounded-[5px] bg-muted px-[5px] font-sans text-label font-normal text-muted-foreground`,children:e})}function OB({name:e,align:t=`start`}){let[n]=Ce([`help.shortcuts`]),r=Ee(`theme`),i=r.find(e=>e.checked?.());return(0,G.jsxs)(pB,{children:[(0,G.jsx)(mB,{"aria-label":e?`${e}, from git user.name`:`Account`,className:`rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,children:(0,G.jsx)(kB,{name:e})}),(0,G.jsxs)(wB,{align:t,alignOffset:t===`start`?-25:-10,sideOffset:7,children:[e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 p-2`,children:[(0,G.jsx)(kB,{name:e}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate font-semibold`,title:e,children:e}),(0,G.jsx)(`p`,{className:`text-label font-normal text-muted-foreground`,children:`From git user.name`})]})]}),(0,G.jsx)(SB,{})]}):null,(0,G.jsx)(TB,{action:n,label:`Keyboard shortcuts`}),(0,G.jsxs)(_B,{children:[(0,G.jsxs)(vB,{disabled:r.length===0,className:`${EB} data-disabled:opacity-50`,children:[`Theme`,i?(0,G.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:i.label}):null]}),(0,G.jsx)(yB,{className:`rounded-[10px] ring-border`,children:(0,G.jsx)(bB,{value:i?.id??``,children:r.map(e=>(0,G.jsx)(xB,{value:e.id,onClick:()=>e.run(),className:`h-7 py-0 text-xs`,children:e.label},e.id))})})]}),(0,G.jsx)(gB,{className:EB,render:(0,G.jsx)(`a`,{href:CB.homepage}),children:`Docs`})]})]})}function kB({name:e}){return(0,G.jsx)(`span`,{"aria-hidden":!0,"data-avatar":!0,className:`grid size-[22px] shrink-0 place-items-center rounded-full bg-foreground text-[10px] font-bold text-card`,children:e?ez(e):(0,G.jsx)(vr,{className:`size-3`})})}var AB=[{id:`view.zoomIn`,label:`Zoom in`},{id:`view.zoomOut`,label:`Zoom out`},{id:`view.zoomToFit`,label:`Zoom to fit`}],jB=[{id:`view.zoom50`,label:`50%`},{id:`view.zoom100`,label:`100%`},{id:`view.zoom200`,label:`200%`}],MB=[...AB,...jB].map(e=>e.id);function NB({align:e=`end`,className:t}){let n=(0,y.useRef)(null),r=Ce(MB);return(0,y.useEffect)(()=>{let e=()=>{n.current&&(n.current.textContent=PB(OD.zoom()))};return e(),OD.onZoom(e)},[]),(0,G.jsxs)(pB,{children:[(0,G.jsxs)(mB,{"aria-label":`Zoom`,className:X(`flex h-6 items-center gap-1 rounded-md px-1 text-muted-foreground tabular-nums outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 aria-expanded:text-foreground`,t),children:[(0,G.jsx)(`span`,{ref:n,"data-zoom-level":!0}),(0,G.jsx)(dt,{"aria-hidden":!0,className:`size-2.5`})]}),(0,G.jsxs)(wB,{align:e,sideOffset:8,className:`w-48`,children:[AB.map((e,t)=>(0,G.jsx)(TB,{action:r[t],label:e.label},e.id)),(0,G.jsx)(SB,{}),jB.map((e,t)=>(0,G.jsx)(TB,{action:r[AB.length+t],label:e.label,children:e.label},e.id))]})]})}function PB(e){return`${Math.round(e*100)}%`}function FB({project:e}){let[t]=Ce([`view.hideUi`]),n=iz()??null;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`absolute top-3 left-3 z-10 flex max-w-[calc(100%-10rem)] items-center gap-1.5 rounded-lg border border-border bg-card py-1 pr-1.5 pl-2.5 text-panel`,children:[(0,G.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,G.jsx)(fB,{label:`Show UI`,keys:t?.keys,side:`bottom`,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":`Show UI`,onClick:()=>t?.run(),className:`grid size-6 shrink-0 place-items-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:(0,G.jsx)(En,{"aria-hidden":!0,className:`size-[15px]`})})})]}),(0,G.jsxs)(`div`,{className:`absolute top-3 right-3 z-10 flex h-[34px] items-center gap-1.5 rounded-lg border border-border bg-card pr-2.5 pl-1.5`,children:[(0,G.jsx)(OB,{name:n,align:`end`}),(0,G.jsx)(NB,{className:`text-foreground`})]})]})}function IB(){return(0,G.jsx)(`p`,{role:`status`,className:`pointer-events-none absolute top-3.5 left-1/2 z-10 -translate-x-1/2 rounded-full bg-primary px-3 py-1.5 font-medium whitespace-nowrap text-primary-foreground`,children:`Playing. Clicks go to the frames. Esc to edit`})}var LB=[[{id:`tool.move`,label:`Move`,keys:[`v`],icon:bn},{id:`tool.hand`,label:`Hand`,keys:[`h`],icon:Gt},{id:`tool.frame`,label:`Frame`,keys:[`f`],icon:Ut},{id:`tool.note`,label:`Note`,keys:[`n`],icon:mn}],[{id:`edit.undo`,label:`Undo`,icon:gr},{id:`edit.redo`,label:`Redo`,icon:Rn}],[{id:`view.zoomToFit`,label:`Zoom to fit`,keys:[`Shift+Digit1`],icon:fn},{id:`theme.toggle`,label:`Theme`,icon:er,darkIcon:vn}]],RB=[{id:`mode.edit`,label:`Edit`,icon:An},{id:`mode.play`,label:`Play`,icon:Mn}],zB=[...LB.flat(),...RB].map(e=>e.id);function BB(){let e=new Map(Ce(zB).map((e,t)=>[zB[t],e]));return(0,G.jsxs)(`div`,{role:`toolbar`,"aria-label":`Tools`,className:`absolute bottom-4 left-1/2 z-10 flex max-w-[calc(100%-1.5rem)] -translate-x-1/2 items-center gap-0.5 overflow-x-auto rounded-xl border border-border bg-card p-[5px] shadow-[0_6px_24px_rgba(0,0,0,.18),0_1px_3px_rgba(0,0,0,.12)]`,children:[LB.map((t,n)=>(0,G.jsxs)(y.Fragment,{children:[n>0?(0,G.jsx)(UB,{}):null,t.map(t=>(0,G.jsx)(VB,{slot:t,action:e.get(t.id)},t.id))]},t[0]?.id)),(0,G.jsx)(UB,{}),(0,G.jsx)(`div`,{className:`flex shrink-0 rounded-lg bg-muted p-0.5`,children:RB.map(t=>(0,G.jsx)(HB,{slot:t,action:e.get(t.id)},t.id))})]})}function VB({slot:e,action:t}){let{label:n,keys:r,on:i,enabled:a,run:o}=WB(e,t),s=e.icon,c=e.darkIcon;return(0,G.jsx)(fB,{label:n,keys:r,children:(0,G.jsxs)(`button`,{type:`button`,"aria-label":n,"aria-pressed":t?.checked?i:void 0,"aria-disabled":!a||void 0,onClick:o,className:X(`grid size-8 shrink-0 place-items-center rounded-[7px] text-foreground outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:bg-transparent`,i&&`bg-primary text-primary-foreground hover:bg-primary aria-disabled:hover:bg-primary`),children:[(0,G.jsx)(s,{"aria-hidden":!0,className:X(`size-4`,c&&`dark:hidden`)}),c?(0,G.jsx)(c,{"aria-hidden":!0,className:`hidden size-4 dark:block`}):null]})})}function HB({slot:e,action:t}){let{label:n,keys:r,on:i,enabled:a,run:o}=WB(e,t),s=e.icon;return(0,G.jsx)(fB,{label:n,keys:r,children:(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":i,"aria-disabled":!a||void 0,onClick:o,className:X(`flex h-[26px] items-center gap-[5px] rounded-md px-[9px] font-medium text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50`,i&&e.id===`mode.play`?`bg-primary text-primary-foreground hover:text-primary-foreground`:i&&`bg-card text-foreground ring-1 ring-border`),children:[(0,G.jsx)(s,{"aria-hidden":!0,className:`size-3.5`}),n]})})}function UB(){return(0,G.jsx)(`span`,{"aria-hidden":!0,className:`mx-[5px] h-5 w-px shrink-0 bg-border`})}function WB(e,t){let n=t?Se(t):!1;return{label:t?.label??e.label,keys:t?.keys??e.keys,on:t?.checked?.()??!1,enabled:n,run:()=>{t&&n&&t.run()}}}function GB(){return ue()(()=>({open:!1,focusRequest:0}))}var KB=GB();function qB(e){return fe(KB,e)}function JB(e=KB,t=iD){t.setState({hideUi:!1}),e.setState(e=>({open:!0,focusRequest:e.focusRequest+1}))}function YB(e=KB){e.setState({open:!1})}function XB(e=KB,t=iD){(0,y.useEffect)(()=>{let n=be([{id:`find.open`,label:`Find`,group:`tool`,keys:[`$mod+KeyF`],run:()=>JB(e,t),command:{label:`Find frames, elements, and text`,icon:Kn}}]);return()=>{n(),YB(e)}},[e,t])}var ZB=ue()(()=>({session:null})),QB=null;function $B(e,{live:t=yl,unseen:n=AN,go:r=F}={}){eV();let i=OD.page(),a=null,o=()=>{if(a===null)return;let[e=``,n=``]=a.split(`/`),o=tV(a);if(OD.page()!==o){i!==o&&(i=o,r(z(e,n)));return}let s=nV(t.getState().board,a);s&&(a=null,OD.centerOn(s))},s=e=>{e!==null&&(a=e,o())},c=n.subscribe((t,n)=>{let r=TN(t.unseen).filter(t=>t.author?.session===e&&n.unseen[t.frame]?.id!==t.id);s(r.at(-1)?.frame??null)}),l=t.subscribe((t,n)=>{if(!t.listeners.some(t=>t.session===e)){eV();return}let r=Object.values(t.claims).filter(t=>t.session===e&&n.claims[t.frame]?.session!==e);r.length>0?s(r.at(-1)?.frame??null):t.board!==n.board&&o()}),u=OD.onHandMove(eV),d=OD.onAttach(()=>{let e=OD.page();if(e===null)return;let n=t.getState().focus;n!==null&&e===tV(n)&&(i=e),e===i?o():eV()}),f=be([{id:`follow.stop`,label:`Stop following`,group:`changes`,run:eV,command:{label:`Stop following the agent`,icon:on}}]);QB=()=>{f(),d(),u(),l(),c()},ZB.setState({session:e})}function eV(){if(!QB)return;let e=QB;QB=null,e(),ZB.setState({session:null})}function tV(e){let[t=``,n=``]=e.split(`/`);return`${t}/${n}`}function nV(e,t){for(let n of e?.projects??[])for(let e of n.pages){let n=e.frames.find(e=>e.ref===t);if(n)return n.box}return null}function rV({listeners:e,claims:t}){let n=fe(ZB,e=>e.session);if(e.length===0)return null;let r=new Map(Object.values(t).map(e=>[e.session,e.agent]));return(0,G.jsx)(`span`,{className:`ml-1 flex items-center`,children:e.map((e,t)=>{let i=r.has(e.session),a=n===e.session,o=(0,G.jsx)(`span`,{"aria-hidden":!0,className:X(`grid size-[22px] place-items-center rounded-full text-[9px] font-bold text-card shadow-[0_0_0_2px_var(--sidebar)]`,i?`bg-claim`:`bg-[color-mix(in_srgb,var(--claim)_55%,var(--sidebar))]`),children:mP(r.get(e.session)??gP(e.tag))});return(0,G.jsxs)(`button`,{type:`button`,"aria-label":`${e.tag}, ${i?`editing`:`listening`}`,"aria-pressed":a,title:a?`Stop following ${e.tag}`:`Follow ${e.tag}`,"data-editing":i||void 0,onClick:()=>a?eV():$B(e.session),className:X(`rounded-full outline-none hover:brightness-110 focus-visible:ring-2 focus-visible:ring-ring/50`,a?`flex items-center gap-1.5 py-0.5 pr-2 pl-0.5 text-[11px] font-semibold text-claim shadow-[0_0_0_1.5px_var(--claim)]`:t>0&&`-ml-1.5`,a&&t>0&&`ml-1.5`),children:[o,a?`Following`:null]},e.session)})})}function iV(e,t=aV){let n=Z(e=>e.board),[r,i]=(0,y.useState)();return(0,y.useEffect)(()=>{let n=!0;return t(e).catch(()=>null).then(e=>{n&&i(e)}),()=>{n=!1}},[e,n,t]),r}async function aV(e){let t=await(await fetch(`/api/projects/${encodeURIComponent(e)}/tokens`)).json();return t.ok?t.data:null}var oV=[[{id:`arrange.alignLeft`,icon:rt},{id:`arrange.alignCenter`,icon:qe},{id:`arrange.alignRight`,icon:Ze}],[{id:`arrange.alignTop`,icon:tt},{id:`arrange.alignMiddle`,icon:Ge},{id:`arrange.alignBottom`,icon:Ye}],[{id:`arrange.distributeHorizontal`,icon:$e},{id:`arrange.distributeVertical`,icon:at}]],sV=oV.flat().map(({id:e})=>e);function cV(){let e=Ce(sV),t=new Map(e.flatMap(e=>e?[[e.id,e]]:[]));return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-arrange`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-arrange`,className:`mb-2 text-xs font-semibold`,children:`Arrange`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:oV.map(e=>(0,G.jsx)(`div`,{role:`group`,className:`flex gap-0.5 rounded-md bg-input p-0.5`,children:e.map(({id:e,icon:n})=>(0,G.jsx)(lV,{action:t.get(e),icon:n},e))},e[0]?.id))})]})}function lV({action:e,icon:t}){return e?(0,G.jsx)(fB,{label:e.label,keys:e.keys,side:`bottom`,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":e.label,disabled:!Se(e),onClick:e.run,className:`grid h-[22px] w-7 place-items-center rounded-[5px] text-muted-foreground outline-none hover:bg-sidebar hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 active:bg-sidebar disabled:pointer-events-none disabled:opacity-40`,children:(0,G.jsx)(t,{"aria-hidden":!0,className:`size-[13px]`,strokeWidth:1.6})})}):null}var uV=`data-valid`,dV=`data-invalid`,fV={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},pV={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},mV={valid(e){return e===null?null:e?{[uV]:``}:{[dV]:``}}},hV={invalid:void 0,name:void 0,validityData:{state:fV,errors:[],error:``,value:``,initialValue:null},setValidityData:Gs,disabled:void 0,setTouched:Gs,setDirty:Gs,setFilled:Gs,setFocused:Gs,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:pV,registerFieldControl:Gs,validation:{getValidationProps:(e,t=qs)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:Gs,getInputControl:()=>null,commit:async()=>{},change:Gs}},gV=y.createContext(hV);function _V(e=!0){let t=y.useContext(gV);if(t.setValidityData===Gs&&!e)throw Error(Ds(28));return t}var vV=y.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Gs,validationMode:`onSubmit`,submitCountRef:{current:0}});function yV(){return y.useContext(vV)}var bV=y.createContext({controlId:void 0,registerControlId:Gs,resetControlId:Gs,labelId:void 0,setLabelId:Gs,messageIds:[],setMessageIds:Gs,getDescriptionProps:e=>e});function xV(){return y.useContext(bV)}function SV(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=xV(),o=OI(),s=os(()=>Symbol()),c=y.useRef(!1),l=y.useRef(!1),u=J(()=>{c.current&&i!==Gs&&(c.current=!1,i(s.current,void 0))});return Y(()=>{if(!n||i===Gs){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}e===void 0?u():(c.current=!0,i(s.current,e))},[t,n,i,a,o,s,u]),Y(()=>u,[u]),(n?r:void 0)??t??o}function CV(e,t,n){let{setFocused:r,focusOwnerRef:i}=_V(),a=J(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return Y(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}function wV(e,t,n,r,i=!0,a){let{registerFieldControl:o}=_V(),s=os(()=>Symbol());Y(()=>{let c=s.current;i?o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}):o(c,void 0)},[e,i,r,t,a,o,s,n]),Y(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var TV=y.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFilled:b,validationMode:x,validation:S}=_V(),{clearErrors:C,elementRef:w,submitCountRef:T}=yV(),E=h||s,D=m??a,O={...p,disabled:E},{labelId:k}=xV(),A=SV({id:i}),j=o!==void 0,M=o==null?void 0:String(o),N=J(()=>S.inputRef.current?.value);wV(S.inputRef,A,M,N,!E,a),Y(()=>{let e=M??S.inputRef.current?.value;e!==void 0&&b(e!==``)},[M,l,S.inputRef,b]),GL(M,()=>{M!==void 0&&(C(D),_(M!==(v.initialValue??``)),S.change(M))});let P=y.useRef(null),F=CV(E,P),I=hu();return Zs(`input`,e,{ref:[t,P],state:O,props:[{id:A,disabled:E,name:D,ref:S.inputRef,"aria-labelledby":k,autoFocus:u,...j?{value:o}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=jp(Np,e.nativeEvent);c?.(t,n),!j&&(_(t!==(v.initialValue??``)),b(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(C(D),S.change(t)))},onFocus(){F(!0)},onBlur(e){if(g(!0),F(!1),x===`onBlur`){let t=e.currentTarget.value;S.commit(t),j&&queueMicrotask(()=>{let e=S.inputRef.current?.value;e!==void 0&&e!==t&&e!==(v.initialValue??``)&&S.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){g(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===w.current&&!e.defaultPrevented){let t=e.currentTarget,n=T.current;I.start(0,()=>{T.current===n&&S.commit(t.value)})}else S.commit(t)}}},f,e=>S.getValidationProps(E,e)],stateAttributesMapping:mV})}),EV=y.forwardRef(function(e,t){return(0,G.jsx)(TV,{ref:t,...e})});function DV({className:e,type:t,...n}){return(0,G.jsx)(EV,{type:t,"data-slot":`input`,className:X(`h-[26px] w-full min-w-0 rounded-md border-0 bg-input px-2 text-xs text-foreground tabular-nums outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-2 aria-invalid:ring-destructive/40`,e),...n})}function OV({label:e,prefix:t,shown:n,disabled:r,onCommit:i,className:a,inset:o=`pl-[26px]`,inputClassName:s}){let[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(null);u&&u.over!==n&&d(null);let f=u?.over===n?u.value:null,p=(0,y.useRef)(!1),m=()=>{if(p.current){p.current=!1;return}if(c===null)return;l(null);let e=c.trim();e!==n&&(d({value:e,over:n}),i(e).then(e=>{e||d(null)}))};return(0,G.jsxs)(`label`,{className:X(`relative block`,a),children:[t?(0,G.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2 flex -translate-y-1/2 items-center text-xs text-faint`,children:t}):null,(0,G.jsx)(DV,{"aria-label":e,className:X(t?o:void 0,s),value:c??f??n,disabled:r,onFocus:e=>e.currentTarget.select(),onChange:e=>l(e.currentTarget.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&(l(null),p.current=!0,e.currentTarget.blur())}})]})}var kV=/^#[0-9a-f]{6}$/i,AV=`flex h-[26px] items-center gap-2 rounded-md bg-input px-2 text-xs`,jV=`-ml-1 max-w-max truncate rounded-[4px] bg-[color-mix(in_srgb,var(--foreground)_9%,transparent)] px-1.5 py-px`;function MV(e,t){let n=`token`in e?`var(${e.token})`:e.raw;if(t>=100)return n;if(`raw`in e&&kV.test(e.raw)){let n=Math.round(t/100*255).toString(16).padStart(2,`0`);return`${e.raw}${n}`}return`color-mix(in srgb, ${n} ${t}%, transparent)`}function NV(e,t,n){return e.find(e=>e.name===t)?.[n]??null}function PV(e,t,n){let r=e.token?NV(t,e.token,n):e.value;return r===null?null:e.percent>=100?r:`color-mix(in srgb, ${r} ${e.percent}%, transparent)`}function FV(e){return e.replace(/^--/,``)}function IV(e){let t=Number(e.replace(/%$/,``).trim());return e.trim()===``||!Number.isFinite(t)?null:Math.min(100,Math.max(0,Math.round(t)))}function LV(e,t){let n=t!==``&&e.endsWith(t)?e.slice(0,-t.length):e,r=Number(n.trim());return n.trim()===``||!Number.isFinite(r)?null:Math.max(0,Math.round(r))}function RV({color:e,className:t}){return(0,G.jsx)(`span`,{"aria-hidden":!0,className:X(`size-3.5 shrink-0 rounded-[3px] shadow-[inset_0_0_0_1px_rgba(127,127,127,.3)]`,e===null&&`border border-dashed border-faint`,t),style:e===null?void 0:{background:e}})}function zV(){return(0,G.jsx)(`span`,{role:`img`,"aria-label":`Raw value, not a token`,title:`Raw value`,children:(0,G.jsx)(ht,{"aria-hidden":!0,className:`size-[13px] text-note`})})}function BV({label:e,value:t,tokens:n,theme:r,disabled:i,onWrite:a}){let o=t.token?{token:t.token}:{raw:t.value},s=t.token?NV(n,t.token,r):null,c=PV(t,n,r),l=t.token!==null||kV.test(t.value);return(0,G.jsxs)(`div`,{className:AV,children:[(0,G.jsx)(VV,{label:`${e} color`,color:c!==null&&kV.test(c)?c:null,disabled:i,onPick:e=>a(MV({raw:e},t.percent)),children:(0,G.jsx)(RV,{color:c})}),(0,G.jsxs)(pB,{children:[(0,G.jsx)(mB,{"aria-label":`${e} token`,disabled:i||n.length===0,className:X(`min-w-0 truncate text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-default`,t.token?jV:`flex-1 tabular-nums`),children:t.token?FV(t.token):t.value.replace(/^#/,``)}),(0,G.jsx)(wB,{align:`start`,sideOffset:6,className:`w-52`,children:n.map(e=>(0,G.jsxs)(gB,{className:EB,onClick:()=>void a(MV({token:e.name},t.percent)),children:[(0,G.jsx)(RV,{color:e[r]}),FV(e.name)]},e.name))})]}),(0,G.jsx)(OV,{label:`${e} opacity`,className:`ml-auto w-12 shrink-0`,inputClassName:`h-6 px-0 text-right text-muted-foreground focus-visible:text-foreground`,shown:`${t.percent}%`,disabled:i||!l,onCommit:async e=>{let t=IV(e);return t!==null&&a(MV(o,t))}}),t.token?(0,G.jsx)(`button`,{type:`button`,"aria-label":`Detach ${FV(t.token)}`,title:`Detach the token to its value`,disabled:i||s===null,onClick:()=>{s!==null&&a(MV({raw:s},t.percent))},className:`grid shrink-0 place-items-center rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 disabled:opacity-50`,children:(0,G.jsx)($t,{"aria-hidden":!0,className:`size-[13px]`})}):(0,G.jsx)(zV,{})]})}function VV({label:e,color:t,disabled:n,onPick:r,children:i}){let a=(0,y.useRef)(null),o=(0,y.useRef)(r);return(0,y.useEffect)(()=>{o.current=r}),(0,y.useEffect)(()=>{a.current&&(a.current.value=t??`#000000`)},[t]),(0,y.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>void o.current(e.value);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,G.jsxs)(`label`,{className:`relative grid shrink-0 place-items-center`,children:[i,(0,G.jsx)(`input`,{ref:a,type:`color`,"aria-label":e,disabled:n,className:`absolute inset-0 size-full cursor-default opacity-0 disabled:pointer-events-none`})]})}function HV({title:e,add:t,children:n}){let r=`inspector-${e.toLowerCase()}`;return(0,G.jsxs)(`section`,{"aria-labelledby":r,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{id:r,className:`text-xs font-semibold`,children:e}),(0,G.jsx)(`button`,{type:`button`,"aria-label":t.label,disabled:t.disabled,onClick:t.onAdd,className:`grid size-5 place-items-center rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50`,children:(0,G.jsx)(Pn,{"aria-hidden":!0,className:`size-[13px]`})})]}),n?(0,G.jsx)(`div`,{className:`mt-2`,children:n}):null]})}function UV({textOnly:e,color:t,backgroundColor:n,tokens:r,theme:i,disabled:a,write:o}){let s=e?`color`:`background-color`,c=e?t:n,l=r[0],u=e=>o({kind:`style`,property:s,value:e});return(0,G.jsx)(HV,{title:`Fill`,add:{label:`Add fill`,disabled:a||c!==null||!l,onAdd:()=>{l&&u(`var(${l.name})`)}},children:c?(0,G.jsx)(BV,{label:`Fill`,value:c,tokens:r,theme:i,disabled:a,onWrite:u}):null})}function WV({name:e,opacity:t,radius:n,disabled:r,write:i}){return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-element`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-element`,className:`mb-2 text-xs font-semibold`,children:`Element`}),(0,G.jsx)(OV,{label:`Name`,className:`mb-1.5`,shown:e,disabled:r,onCommit:e=>i({kind:`attribute`,name:`data-name`,value:e})}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,G.jsx)(OV,{label:`Opacity`,prefix:(0,G.jsx)(xt,{className:`size-1.5 fill-current`}),inset:`pl-[28px]`,shown:`${Math.round(t*100)}%`,disabled:r,onCommit:async e=>{let t=IV(e);return t!==null&&i({kind:`style`,property:`opacity`,value:String(t/100)})}}),(0,G.jsx)(OV,{label:`Corner radius`,prefix:(0,G.jsx)(Xn,{className:`size-3`}),inset:`pl-[28px]`,shown:String(n),disabled:r,onCommit:async e=>{let t=LV(e,`px`);return t!==null&&i({kind:`style`,property:`border-radius`,value:`${t}px`})}})]})]})}function GV({boxShadow:e,shadows:t,theme:n,disabled:r,write:i}){let a=!e||e.value.trim().toLowerCase()===`none`,o=a?null:e.token?NV(t,e.token,n):e.value,s=e=>void i({kind:`style`,property:`box-shadow`,value:e});return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-shadow`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-shadow`,className:`mb-2 text-xs font-semibold`,children:`Shadow`}),(0,G.jsxs)(pB,{children:[(0,G.jsxs)(mB,{"aria-label":`Shadow`,disabled:r,className:`${AV} w-full text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,G.jsx)(KV,{shadow:o}),a?(0,G.jsx)(`span`,{className:`flex-1 text-muted-foreground`,children:`None`}):e.token?(0,G.jsx)(`span`,{className:jV,children:FV(e.token)}):(0,G.jsx)(`span`,{className:`flex-1 truncate`,children:e.value}),!a&&!e.token?(0,G.jsx)(zV,{}):null,(0,G.jsx)(dt,{"aria-hidden":!0,className:`ml-auto size-2.5 shrink-0 text-muted-foreground`})]}),(0,G.jsxs)(wB,{align:`start`,sideOffset:6,className:`w-52`,children:[t.map(e=>(0,G.jsxs)(gB,{className:EB,onClick:()=>s(`var(${e.name})`),children:[(0,G.jsx)(KV,{shadow:e[n]}),FV(e.name)]},e.name)),t.length>0?(0,G.jsx)(SB,{}):null,(0,G.jsx)(gB,{className:EB,onClick:()=>{a||s(`none`)},children:`None`})]})]})]})}function KV({shadow:e}){return(0,G.jsx)(`span`,{"aria-hidden":!0,className:`size-3.5 shrink-0 rounded-[3px] bg-sidebar shadow-[inset_0_0_0_1px_rgba(127,127,127,.3)]`,style:e?{boxShadow:e}:void 0})}var qV=`--border`;function JV({bordered:e,borderColor:t,tokens:n,theme:r,disabled:i,write:a}){let o=n.find(e=>e.name===qV)?.name??n[0]?.name,s=e?t??{value:`currentcolor`,token:null,percent:100}:null;return(0,G.jsx)(HV,{title:`Stroke`,add:{label:`Add stroke`,disabled:i||e||o===void 0,onAdd:()=>{o!==void 0&&a({kind:`style`,property:`border`,value:`1px solid var(${o})`})}},children:s?(0,G.jsx)(BV,{label:`Stroke`,value:s,tokens:n,theme:r,disabled:i,onWrite:e=>a({kind:`style`,property:`border-color`,value:e})}):null})}function YV(e){let[t,n]=(0,y.useState)(null),r=e?.frame,i=e?.index,a=e?.hash,o=e?`${r}:${i}`:null;return(0,y.useEffect)(()=>{if(r===void 0||i===void 0||o===null)return;let e=document.querySelector(`[data-frame="${CSS.escape(r)}"] iframe`);if(!e)return;let t=()=>{let t=e.contentDocument;if(!t||VN(t)!==a)return;let r=BN(t,i),s=t.defaultView;r&&s&&n({at:o,live:XV(r,s)})};return t(),e.addEventListener(`load`,t),()=>e.removeEventListener(`load`,t)},[r,i,a,o]),t?.at===o?t.live:null}function XV(e,t){let n=t.getComputedStyle(e),r=e.textContent??``,i=[n.borderTopWidth,n.borderRightWidth,n.borderBottomWidth,n.borderLeftWidth];return{opacity:Number(n.opacity),radius:Math.round(parseFloat(n.borderTopLeftRadius)||0),fontSize:Math.round(parseFloat(n.fontSize)*100)/100,fontWeight:Number(n.fontWeight),textAlign:ZV(n.textAlign,n.direction),bordered:i.some(e=>parseFloat(e)>0),holdsText:r.trim()!==``,textOnly:e.childElementCount===0&&r.trim()!==``,text:r}}function ZV(e,t){return e===`start`?t===`rtl`?`right`:`left`:e===`end`?t===`rtl`?`left`:`right`:e}function QV(e,t,n,r=$V){let[i,a]=(0,y.useState)(null),o=e===null?null:`${e}:${t??``}`;return(0,y.useEffect)(()=>{if(e===null||o===null)return;let n=!0;return r(e,t).catch(()=>null).then(e=>{n&&e&&a({at:o,styles:e})}),()=>{n=!1}},[e,t,n,o,r]),i?.at===o?i.styles:null}async function $V(e,t){let n=new URLSearchParams({ref:e});t!==void 0&&n.set(`index`,String(t));let r=await(await fetch(`/api/frames/styles?${n}`)).json();return r.ok?r.data:null}function eH({className:e,...t}){return(0,G.jsx)(`textarea`,{"data-slot":`textarea`,className:X(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function tH({text:e,disabled:t,write:n}){let[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(null);a&&a.over!==e&&o(null);let s=a?.over===e?a.value:null,c=(0,y.useRef)(!1),l=()=>{c.current?c.current=!1:r!==null&&(i(null),r!==e&&(o({value:r,over:e}),n({kind:`text`,value:r}).then(e=>{e||o(null)})))};return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-text`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-text`,className:`mb-2 text-xs font-semibold`,children:`Text`}),(0,G.jsx)(eH,{"aria-labelledby":`inspector-text`,value:r??s??e,disabled:t,onChange:e=>i(e.currentTarget.value),onBlur:l,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),l()),e.key===`Escape`&&(i(null),c.current=!0,e.currentTarget.blur())},className:`min-h-11 resize-none rounded-md border-0 bg-input px-2 py-1.5 text-xs leading-[1.4] md:text-xs dark:bg-input`})]})}var nH=[{value:`left`,label:`Align text left`,icon:cr},{value:`center`,label:`Align text center`,icon:ir},{value:`right`,label:`Align text right`,icon:or}];function rH({fontSize:e,fontWeight:t,textAlign:n,disabled:r,write:i}){return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-typography`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-typography`,className:`mb-2 text-xs font-semibold`,children:`Typography`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,G.jsx)(OV,{label:`Font size`,prefix:`Size`,inset:`pl-[40px]`,shown:String(e),disabled:r,onCommit:async e=>{let t=LV(e,`px`);return t===null||t===0?!1:i({kind:`style`,property:`font-size`,value:`${t}px`})}}),(0,G.jsx)(OV,{label:`Font weight`,prefix:`Wt`,inset:`pl-[32px]`,shown:String(t),disabled:r,onCommit:async e=>{let t=LV(e,``);return t===null||t<1||t>1e3?!1:i({kind:`style`,property:`font-weight`,value:String(t)})}})]}),(0,G.jsx)(`div`,{className:`mt-1.5 flex w-max gap-0.5 rounded-md bg-input p-0.5`,children:nH.map(({value:e,label:t,icon:a})=>(0,G.jsx)(`button`,{type:`button`,"aria-label":t,"aria-pressed":n===e,disabled:r,onClick:()=>{n!==e&&i({kind:`style`,property:`text-align`,value:e})},className:X(`grid h-[22px] w-7 place-items-center rounded-[5px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50`,n===e&&`bg-sidebar text-foreground`),children:(0,G.jsx)(a,{"aria-hidden":!0,className:`size-[13px]`})},e))})]})}var iH=new Map;function aH(e,t,n,r={}){let i=oH(iH.get(t.frame),e,t,n,r);return iH.set(t.frame,i),i.then(e=>(iH.get(t.frame)===i&&iH.delete(t.frame),e!==null))}async function oH(e,t,n,r,{selection:i=bD,send:a=fetch,notify:o=e=>E_.add({...e,type:`warning`,timeout:0})}){let s=e?await e:void 0;if(s===null)return vD(i,sH),null;let c=s!==void 0&&s.from.includes(n.hash),l=c?s.to:n.hash,u=()=>{};try{let e=await xE([n.frame],`edit`,async()=>{u=mD(n.frame),gD(n.frame,l);try{return await Ml(`/api/frames/edit`,{ref:n.frame,index:n.index,hash:l,change:r},`POST`,a)}catch(e){throw u(),e}});gD(n.frame,e.hash);let o=i.getState().element;return o?.frame===n.frame&&o.index===n.index&&cD(i,t,{...n,hash:e.hash}),u(),yD(i,sH),{from:c?[...s.from,l]:[n.hash],to:e.hash}}catch(e){return e instanceof pE||o({title:`Edit not saved`,description:e instanceof jl?cH(e.message):`The board could not be reached, so nothing was written.`}),u(),vD(i,sH),null}}function sH(e){let t=document.querySelector(`[data-frame="${CSS.escape(e)}"] iframe`)?.contentDocument;return t?VN(t):null}function cH(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return/[.!?]$/.test(t)?t:`${t}.`}function lH({name:e,label:t,onCommit:n,onCancel:r}){let i=(0,y.useRef)(null),a=(0,y.useRef)(!1);(0,y.useEffect)(()=>{i.current?.focus(),i.current?.select()},[]);let o=t=>{if(a.current)return;a.current=!0;let o=i.current?.value.trim()??``;t&&o!==``&&o!==e?n(o):r()};return(0,G.jsx)(`input`,{ref:i,"aria-label":t,defaultValue:e,spellCheck:!1,onClick:e=>e.preventDefault(),onKeyDown:e=>{if(e.key===`Enter`)o(!0);else if(e.key===`Escape`)o(!1);else return;e.preventDefault(),e.stopPropagation()},onBlur:()=>o(!0),className:`-ml-1.5 h-[22px] min-w-0 flex-1 rounded-[5px] bg-background px-1.5 text-foreground ring-[1.5px] ring-primary outline-none selection:bg-primary/45`})}var uH=[{key:`x`,letter:`X`,label:`X position`},{key:`y`,letter:`Y`,label:`Y position`},{key:`width`,letter:`W`,label:`Width`},{key:`height`,letter:`H`,label:`Height`}];function dH({frames:e,page:t,named:n=!0,write:r=IE,calls:i}){let a=Z(e=>e.canWrite),o=WF(`inspector`),[s]=e;if(!s)return null;let c=e.length>1,l=e.some(e=>e.locked),u=(n,i)=>{let a={},o={};for(let{ref:t,box:r}of e){let e={...r,[n]:i};e[n]!==r[n]&&(a[t]=e,o[t]=r)}r(t,a,o)};return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-frame`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-frame`,className:`mb-2 text-xs font-semibold`,children:c?`${e.length} frames`:`Frame`}),c||!n?null:o===s.ref?(0,G.jsx)(`div`,{className:`mb-1.5 flex h-[26px] items-center pl-1.5`,children:(0,G.jsx)(lH,{name:s.name,label:`Rename frame ${s.name}`,onCommit:e=>{KF(),qF(s,e,i)},onCancel:KF})}):(0,G.jsx)(`button`,{type:`button`,"aria-label":`Rename frame ${s.name}`,disabled:!a,onClick:()=>GF(s.ref,`inspector`),className:`mb-1.5 block h-[26px] w-full truncate rounded-md bg-input px-2 text-left text-xs outline-none hover:ring-1 hover:ring-border focus-visible:ring-2 focus-visible:ring-ring/50 disabled:hover:ring-0`,children:s.name}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:uH.map(({key:t,letter:n,label:r})=>(0,G.jsx)(fH,{letter:n,label:r,value:pH(e.map(({box:e})=>e[t])),min:t===`width`||t===`height`?1:void 0,disabled:!a||l,onCommit:e=>u(t,e)},t))})]})}function fH({letter:e,label:t,value:n,min:r,disabled:i,onCommit:a}){let o=n===null?`Mixed`:String(n),[s,c]=(0,y.useState)(null),l=()=>{if(s===null)return;c(null);let e=Number(s.trim());s.trim()!==o&&Number.isInteger(e)&&a(r===void 0?e:Math.max(r,e))};return(0,G.jsxs)(`label`,{className:`relative block`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2 -translate-y-1/2 text-xs text-faint`,children:e}),(0,G.jsx)(DV,{"aria-label":t,inputMode:`numeric`,className:`pl-[26px]`,value:s??o,disabled:i,onFocus:e=>e.currentTarget.select(),onChange:e=>c(e.currentTarget.value),onBlur:l,onKeyDown:e=>{e.key===`Enter`&&l(),e.key===`Escape`&&(c(null),e.currentTarget.blur())}})]})}function pH(e){let[t]=e;return t!==void 0&&e.every(e=>e===t)?t:null}function mH({colors:e,tokens:t,theme:n}){return e.length===0?null:(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-selection-colors`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-selection-colors`,className:`mb-2 text-xs font-semibold`,children:`Selection colors`}),(0,G.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.map(e=>(0,G.jsxs)(`li`,{className:AV,children:[(0,G.jsx)(RV,{color:PV(e,t,n)}),e.token?(0,G.jsx)(`span`,{className:jV,children:FV(e.token)}):(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate tabular-nums`,children:e.value.replace(/^#/,``)}),(0,G.jsxs)(`span`,{className:`ml-auto text-muted-foreground tabular-nums`,children:[e.percent,`%`]}),e.token?(0,G.jsx)($t,{role:`img`,"aria-label":`Token`,className:`size-[13px] shrink-0 text-muted-foreground`}):(0,G.jsx)(zV,{})]},`${e.token??e.value}:${e.percent}`))})]})}function hH(){let e=iz()??null,t=aD(e=>e.mode===`play`),n=aD(e=>e.mode===`edit`&&e.tool===`frame`),r=Z(e=>e.listeners),i=Z(e=>e.claims),a=xD(e=>e.page),o=xD(e=>e.frames),s=xD(e=>e.element??null),c=jE(Z(e=>e.board?.projects.flatMap(e=>e.pages).find(e=>e.ref===a))?.frames.filter(e=>o.includes(e.ref))??[]),l=s&&c.length===1?s:null;return(0,G.jsxs)(`aside`,{"aria-label":`Inspector`,className:`flex h-full min-w-0 flex-col overflow-y-auto bg-sidebar text-body text-sidebar-foreground`,children:[(0,G.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between border-b border-sidebar-border px-3`,children:[(0,G.jsxs)(`span`,{className:`flex items-center`,children:[(0,G.jsx)(OB,{name:e}),(0,G.jsx)(rV,{listeners:r,claims:i})]}),(0,G.jsx)(NB,{})]}),n?(0,G.jsx)(xH,{}):a&&c.length>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dH,{page:a,frames:c,named:!l}),c.length>1?(0,G.jsx)(cV,{}):null,l?(0,G.jsx)(vH,{page:a,element:l}):(0,G.jsx)(yH,{frames:c})]}):(0,G.jsx)(`div`,{className:`px-3 pt-2.5 pb-3 text-muted-foreground`,children:t?(0,G.jsx)(`p`,{children:`Playing. Nothing selects while frames take the clicks.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{children:`Select a frame to see its details.`}),(0,G.jsx)(`p`,{className:`mt-4`,children:`Click a frame, or drag on the canvas to select several.`})]})})]})}var gH=`--shadow`;function _H(e){let t=iV(e.split(`/`)[0]??``)?.tokens??[];return{colors:t.filter(e=>e.group===`color`&&!e.name.startsWith(gH)),shadows:t.filter(e=>e.name.startsWith(gH))}}function vH({page:e,element:t}){let n=Z(e=>e.canWrite),r=nv(t.frame),i=YV(t),a=QV(t.frame,t.index,t.hash),o=PP(t.frame),{colors:s,shadows:c}=_H(t.frame),l=o?.status===`ready`?o.tree.elements.find(({index:e})=>e===t.index):void 0;if(!i)return(0,G.jsx)(`p`,{className:`px-3 pt-2.5 pb-3 text-muted-foreground`,children:`The element’s details show once its frame is on screen.`});let u=!n,d=n=>aH(e,t,n),f=a?.element;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(WV,{name:l?.name??``,opacity:i.opacity,radius:i.radius,disabled:u,write:d}),i.holdsText?(0,G.jsx)(rH,{fontSize:i.fontSize,fontWeight:i.fontWeight,textAlign:i.textAlign,disabled:u,write:d}):null,(0,G.jsx)(UV,{textOnly:i.textOnly,color:f?.color??null,backgroundColor:f?.backgroundColor??null,tokens:s,theme:r,disabled:u,write:d}),i.textOnly?(0,G.jsx)(tH,{text:i.text,disabled:u,write:d}):null,(0,G.jsx)(JV,{bordered:i.bordered,borderColor:f?.borderColor??null,tokens:s,theme:r,disabled:u,write:d}),(0,G.jsx)(GV,{boxShadow:f?.boxShadow??null,shadows:c,theme:r,disabled:u,write:d}),(0,G.jsx)(mH,{colors:a?.colors??[],tokens:s,theme:r})]})}function yH({frames:e}){let[t]=e,n=nv(t?.ref??``),{colors:r}=_H(t?.ref??``),i=e.map(e=>e.ref).join(`
64
+ `),"data-severity":n,className:`flex h-[18px] shrink-0 items-center gap-[3px] rounded-[9px] bg-[color-mix(in_srgb,var(--h)_34%,transparent)] pr-1.5 pl-[5px] font-medium text-[color-mix(in_srgb,var(--h)_55%,var(--foreground))] shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--h)_75%,transparent)] data-[severity=error]:[--h:var(--destructive)] data-[severity=warning]:[--h:var(--note)]`,children:[(0,G.jsx)(fr,{"aria-hidden":!0,className:`size-3 text-[var(--h)]`}),t]})}function aF(e,t){let n=Object.entries(e),r=DE(n.map(([,e])=>e));if(!r||n.length<2)return{...e};let i=e=>{switch(t){case`left`:return{...e,x:r.x};case`center`:return{...e,x:Math.round(r.x+(r.width-e.width)/2)};case`right`:return{...e,x:r.x+r.width-e.width};case`top`:return{...e,y:r.y};case`middle`:return{...e,y:Math.round(r.y+(r.height-e.height)/2)};case`bottom`:return{...e,y:r.y+r.height-e.height}}};return Object.fromEntries(n.map(([e,t])=>[e,i(t)]))}function oF(e,t){let n=Object.entries(e);if(n.length<3)return{...e};let r=e=>t===`horizontal`?e.x:e.y,i=e=>t===`horizontal`?e.width:e.height,a=n.toSorted(([,e],[,t])=>r(e)-r(t)||i(e)-i(t)),[,o]=a[0]??[],[,s]=a.at(-1)??[];if(!o||!s)return{...e};let c=(r(s)+i(s)-r(o)-a.reduce((e,[,t])=>e+i(t),0))/(a.length-1),l={},u=r(o);for(let[e,n]of a){let r=Math.round(u);l[e]=t===`horizontal`?{...n,x:r}:{...n,y:r},u+=i(n)+c}return l}var sF=[{name:`Left`,key:`ArrowLeft`,dx:-1,dy:0},{name:`Right`,key:`ArrowRight`,dx:1,dy:0},{name:`Up`,key:`ArrowUp`,dx:0,dy:-1},{name:`Down`,key:`ArrowDown`,dx:0,dy:1}],cF=[{id:`arrange.alignLeft`,label:`Align left`,alignment:`left`,key:`Alt+KeyA`},{id:`arrange.alignCenter`,label:`Align horizontal centers`,alignment:`center`,key:`Alt+KeyH`},{id:`arrange.alignRight`,label:`Align right`,alignment:`right`,key:`Alt+KeyD`},{id:`arrange.alignTop`,label:`Align top`,alignment:`top`,key:`Alt+KeyW`},{id:`arrange.alignMiddle`,label:`Align vertical centers`,alignment:`middle`,key:`Alt+KeyV`},{id:`arrange.alignBottom`,label:`Align bottom`,alignment:`bottom`,key:`Alt+KeyS`}],lF=[{id:`arrange.distributeHorizontal`,label:`Distribute horizontal spacing`,axis:`horizontal`,key:`Control+Alt+KeyH`},{id:`arrange.distributeVertical`,label:`Distribute vertical spacing`,axis:`vertical`,key:`Control+Alt+KeyV`}];function uF(e){let{selection:t,mode:n,live:r}=e,i=()=>n.getState().mode===`edit`,a=()=>{let{page:n,frames:r}=t.getState();return n===e.page()?e.frames().filter(e=>r.includes(e.ref)):[]},o=e=>()=>{let t=a();return i()&&r.getState().canWrite&&t.length>=e&&t.every(e=>!e.locked)},s=null,c,l=()=>{clearTimeout(c);let t=s;s=null,t&&e.write(t.page,t.boxes,t.started)},u=t=>{let n=a(),r=e.page(),i=n.map(e=>e.ref);s&&(s.page!==r||!fF(s.refs,i))&&l(),s||={page:r,refs:i,started:pF(n),boxes:pF(n)};let{boxes:o}=s;for(let e of n){let n=o[e.ref]??e.box;o[e.ref]=t(n)}e.hold(o),clearTimeout(c),c=setTimeout(l,300)},d=t=>{let n=pF(a()),r=t(n),i=Object.keys(r).filter(e=>{let t=r[e],i=n[e];return t&&i&&(t.x!==i.x||t.y!==i.y)});e.write(e.page(),mF(r,i),mF(n,i))};return[{id:`selection.clear`,label:`Clear selection`,group:`selection`,keys:[`Escape`],enabled:()=>i()&&t.getState().frames.length>0,run:()=>uD(t)},{id:`selection.all`,label:`Select all`,group:`selection`,command:{label:`Select all`},keys:[`$mod+KeyA`],enabled:()=>i()&&e.frames().length>0,run:()=>sD(t,e.page(),e.frames().map(e=>e.ref))},...sF.flatMap(({name:e,key:t,dx:n,dy:r})=>[{id:`frame.nudge${e}`,label:`Nudge ${e.toLowerCase()}`,group:`frame`,keys:[t],enabled:o(1),run:()=>u(e=>({...e,x:e.x+n,y:e.y+r}))},{id:`frame.nudge${e}Far`,label:`Nudge ${e.toLowerCase()} 10 px`,group:`frame`,keys:[`Shift+${t}`],enabled:o(1),run:()=>u(e=>({...e,x:e.x+n*10,y:e.y+r*10}))},{id:`frame.resize${e}`,label:n===0?r>0?`Make taller`:`Make shorter`:n>0?`Make wider`:`Make narrower`,group:`frame`,keys:[`$mod+${t}`],enabled:o(1),run:()=>u(e=>({...e,width:Math.max(1,e.width+n),height:Math.max(1,e.height+r)}))}]),...cF.map(({id:e,label:t,alignment:n,key:r})=>({id:e,label:t,group:`arrange`,command:{label:t},keys:[r],enabled:o(2),run:()=>d(e=>aF(e,n))})),...lF.map(({id:e,label:t,axis:n,key:r})=>({id:e,label:t,group:`arrange`,command:{label:t},keys:[r],enabled:o(3),run:()=>d(e=>oF(e,n))}))]}function dF(e,t){let n=(0,y.useRef)(e),r=(0,y.useRef)(t);(0,y.useEffect)(()=>{n.current=e,r.current=t},[e,t]),(0,y.useEffect)(()=>{let e=be(uF({page:()=>n.current,frames:()=>ME(r.current),selection:bD,mode:iD,live:yl,hold:PE,write:IE})),t=[bD.subscribe(xe),yl.subscribe(xe)];return()=>{for(let e of t)e();e()}},[])}function fF(e,t){return e.length===t.length&&e.every(e=>t.includes(e))}function pF(e){return Object.fromEntries(e.map(e=>[e.ref,e.box]))}function mF(e,t){return Object.fromEntries(t.flatMap(t=>{let n=e[t];return n?[[t,n]]:[]}))}function hF(e,t,n){let r=6/n,i=(e,t)=>Math.abs(e-t)<=r,a=i(t.x,e.x),o=i(t.x,e.x+e.width),s=i(t.y,e.y),c=i(t.y,e.y+e.height);return s&&a?`nw`:s&&o?`ne`:c&&a?`sw`:c&&o?`se`:null}function gF(e,t,n){let r=6/n,i=(e,t,n)=>e>=t-r&&e<=n+r,a=(e,t)=>Math.abs(e-t)<=r,o=e.x+e.width,s=e.y+e.height;return i(t.x,e.x,o)&&(a(t.y,e.y)||a(t.y,s))||i(t.y,e.y,s)&&(a(t.x,e.x)||a(t.x,o))}function _F(e){let t=e.querySelector(`[data-element-selection]`);if(!t)return null;let{left:n,top:r,width:i,height:a}=t.style;return{x:parseFloat(n),y:parseFloat(r),width:parseFloat(i),height:parseFloat(a)}}function vF(e,t,n){let r=20/n;for(let n=e.length-1;n>=0;--n){let i=e[n];if(!i||i.hidden)continue;let{x:a,y:o,width:s,height:c}=i.box;if(t.x>=a&&t.x<=a+s&&t.y>=o-r&&t.y<=o+c)return i}return null}function yF(e,t){return e.filter(({hidden:e,box:n})=>!e&&n.x<=t.x+t.width&&n.x+n.width>=t.x&&n.y<=t.y+t.height&&n.y+n.height>=t.y)}function bF(e,t,n){let r=n.width/t.width,i=n.height/t.height;return Object.fromEntries(Object.entries(e).map(([e,a])=>{let o=Math.round(n.x+(a.x-t.x)*r),s=Math.round(n.y+(a.y-t.y)*i),c=Math.round(n.x+(a.x+a.width-t.x)*r),l=Math.round(n.y+(a.y+a.height-t.y)*i);return[e,{x:o,y:s,width:Math.max(1,c-o),height:Math.max(1,l-s)}]}))}function xF(e,t,n,r){let i=t===`nw`||t===`sw`,a=t===`nw`||t===`ne`,o=Math.round(e.x),s=Math.round(e.y),c=Math.round(e.x+e.width),l=Math.round(e.y+e.height),u=i?Math.min(Math.round(o+n),c-1):o,d=a?Math.min(Math.round(s+r),l-1):s;return{x:u,y:d,width:i?c-u:Math.max(1,Math.round(c+n)-o),height:a?l-d:Math.max(1,Math.round(l+r)-s)}}var SF=[`start`,`center`,`end`];function CF(e,t,n){let r=TF(e,t,`x`,SF,n),i=TF(e,t,`y`,SF,n);return DF({...e,x:Math.round(e.x+(r?.delta??0)),y:Math.round(e.y+(i?.delta??0))},r,i)}function wF(e,t,n,r){let i=TF(e,n,`x`,[t.x],r),a=TF(e,n,`y`,[t.y],r),o={...e},s=Math.round(i?.delta??0),c=Math.round(a?.delta??0);return t.x===`start`?(o.x+=s,o.width-=s):o.width+=s,t.y===`start`?(o.y+=c,o.height-=c):o.height+=c,o.width<1||o.height<1?{box:e,guides:[],gaps:[]}:DF(o,i,a)}function TF(e,t,n,r,i){let a=null;for(let o of r.map(t=>EF(e,n,t)))for(let e of t)for(let t of SF.map(t=>EF(e,n,t))){let n=t-o;Math.abs(n)>i||a&&Math.abs(n)>Math.abs(a.delta)||(a&&n===a.delta&&t===a.at?a.targets.includes(e)||a.targets.push(e):a={delta:n,at:t,targets:[e]})}return a}function EF(e,t,n){let r=t===`x`?e.x:e.y,i=t===`x`?e.width:e.height;return n===`start`?r:n===`end`?r+i:r+i/2}function DF(e,t,n){let r=[];if(t){let n=[e,...t.targets];r.push({axis:`x`,at:t.at,from:Math.min(...n.map(e=>e.y)),to:Math.max(...n.map(e=>e.y+e.height))})}if(n){let t=[e,...n.targets];r.push({axis:`y`,at:n.at,from:Math.min(...t.map(e=>e.x)),to:Math.max(...t.map(e=>e.x+e.width))})}let i=[],a=n?OF(e,n.targets,`x`):null;a&&i.push(a);let o=t?OF(e,t.targets,`y`):null;return o&&i.push(o),{box:e,guides:r,gaps:i}}function OF(e,t,n){let r=null,i=e=>n===`x`?e.x:e.y,a=e=>i(e)+(n===`x`?e.width:e.height),o=n===`x`?e.y+e.height/2:e.x+e.width/2;for(let s of t){let t=a(s)<=i(e)?{from:a(s),to:i(e)}:a(e)<=i(s)?{from:a(e),to:i(s)}:null;!t||t.to-t.from<=0||r&&r.to-r.from<=t.to-t.from||(r={axis:n,at:o,...t})}return r}var kF={selection:bD,mode:iD,canWrite:()=>yl.getState().canWrite,write:IE};function AF(e,t,n=kF){let{selection:r,mode:i}=n,a={kind:`none`},o={x:0,y:0},s={x:0,y:0},c=!1,l=null,u=new Map,d=()=>t.layer.querySelector(`[data-overlay]`),f=()=>sN(t.viewport).k,p=e=>{let[n,r]=Vk(e,t.viewport),{x:i,y:a,k:o}=sN(t.viewport);return{x:(n-i)/o,y:(r-a)/o}},m=e=>{let{page:n,frames:i}=r.getState();return n===t.page?e.filter(e=>i.includes(e.ref)):[]},h=e=>Object.fromEntries(e.map(e=>[e.ref,e.box])),g=e=>{let n=ME(t.frames()),i=p(e);o=i,s={x:e.clientX,y:e.clientY},c=!1,l=e;let u=r.getState().element,d=u?_F(t.layer):null;if(d&&gF(d,i,f())){a={kind:`none`};return}let g=m(n),_=DE(g.map(e=>e.box)),v=_&&!u?hF(_,i,f()):null;if(_&&v){a={kind:`resize`,corner:v,boxes:h(g),bounds:_};return}let y=vF(n,i,f());y?(!e.shiftKey&&!g.some(({ref:e})=>e===y.ref)&&sD(r,t.page,[y.ref]),a={kind:`press`,frame:y,shift:e.shiftKey}):a={kind:`marquee`,shift:e.shiftKey,base:e.shiftKey?r.getState().frames:[]}},_=()=>{if(a.kind===`press`||a.kind===`resize`){if(a.kind===`press`){let{frame:e,shift:i}=a;i&&!r.getState().frames.includes(e.ref)&&lD(r,t.page,e.ref);let o=m(ME(t.frames())),s=DE(o.map(({box:e})=>e));a=s&&o.every(({locked:e})=>!e)&&n.canWrite()?{kind:`move`,boxes:h(o),bounds:s}:{kind:`none`}}else{let e=Object.keys(a.boxes);(t.frames().some(t=>e.includes(t.ref)&&t.locked)||!n.canWrite())&&(a={kind:`none`})}(a.kind===`move`||a.kind===`resize`)&&(u=new Map(Object.keys(a.boxes).flatMap(e=>{let n=t.layer.querySelector(`[data-frame="${CSS.escape(e)}"]`);return n?[[e,n]]:[]})))}},v=e=>{let n=d();if(!n)return;let r=p(e),i=r.x-o.x,s=r.y-o.y,c=e.ctrlKey?-1:6/f(),l=()=>ME(t.frames()).filter(e=>!(`boxes`in a&&e.ref in a.boxes)).map(e=>e.box);switch(a.kind){case`move`:{let{bounds:e,boxes:t}=a,r=CF({...e,x:Math.round(e.x+i),y:Math.round(e.y+s)},l(),c),o=r.box.x-e.x,d=r.box.y-e.y;for(let[e,n]of Object.entries(t)){let t=u.get(e);t&&(t.style.left=`${n.x+o}px`,t.style.top=`${n.y+d}px`)}KN(n,o,d,r.box),YN(n,r.guides,r.gaps);return}case`resize`:{let{bounds:e,boxes:t,corner:r}=a,o=wF(xF(e,r,i,s),{x:r.endsWith(`w`)?`start`:`end`,y:r.startsWith(`n`)?`start`:`end`},l(),c),d=bF(t,e,o.box);for(let[e,t]of Object.entries(d)){let n=u.get(e);n&&Object.assign(n.style,{left:`${t.x}px`,top:`${t.y}px`,width:`${t.width}px`,height:`${t.height}px`})}qN(n,d),YN(n,o.guides,o.gaps);return}case`marquee`:{let e=jF(o,r);JN(n,e,yF(ME(t.frames()),e).map(e=>e.box));return}default:return}},y=e=>{let i=d();if(!c){a.kind===`press`?a.shift?lD(r,t.page,a.frame.ref):sD(r,t.page,[a.frame.ref]):a.kind===`marquee`&&!a.shift&&uD(r),a={kind:`none`};return}i&&XN(i);let s=p(e);if(a.kind===`marquee`){let e=yF(ME(t.frames()),jF(o,s)).map(e=>e.ref);sD(r,t.page,[...a.base,...e])}else if(a.kind===`move`||a.kind===`resize`){let e={},r={};for(let[t,n]of Object.entries(a.boxes)){let i=u.get(t);if(!i)continue;let a={x:parseFloat(i.style.left),y:parseFloat(i.style.top),width:parseFloat(i.style.width),height:parseFloat(i.style.height)};EE(a,n)||(e[t]=a,r[t]=n)}n.write(t.page,e,r)}a={kind:`none`},u=new Map},b=e=>{e.key===`Control`&&c&&l&&v(new MouseEvent(`mousemove`,{clientX:l.clientX,clientY:l.clientY,ctrlKey:e.type===`keydown`}))},x=oA().container(()=>t.viewport).filter(e=>{let{mode:t,tool:n}=i.getState();return e.button===0&&t===`edit`&&n===`move`}).touchable(!1).on(`start`,e=>{g(e.sourceEvent),addEventListener(`keydown`,b),addEventListener(`keyup`,b)}).on(`drag`,e=>{let t=e.sourceEvent;if(l=t,!c){if(Math.hypot(t.clientX-s.x,t.clientY-s.y)<=3)return;c=!0,_()}v(t)}).on(`end`,e=>{removeEventListener(`keydown`,b),removeEventListener(`keyup`,b),y(e.sourceEvent),l=null}),S=e=>{e.ctrlKey&&e.button===0&&e.preventDefault()},C=zk(e);return C.call(x),e.addEventListener(`contextmenu`,S),()=>{C.on(`.drag`,null),e.removeEventListener(`contextmenu`,S),removeEventListener(`keydown`,b),removeEventListener(`keyup`,b)}}function jF(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(e.x-t.x),height:Math.abs(e.y-t.y)}}var MF={$mod:`⌘`,Meta:`⌘`,Control:`⌃`,Alt:`⌥`,Shift:`⇧`},NF=[`Control`,`Alt`,`Shift`,`$mod`,`Meta`],PF={$mod:`Ctrl`,Meta:`Win`,Control:`Ctrl`,Alt:`Alt`,Shift:`Shift`},FF={Backslash:`\\`,Equal:`=`,Minus:`-`,Escape:`Esc`},IF=/Mac|iPod|iPhone|iPad/.test(navigator.platform);function LF(e,t=IF){return RF(e,t).join(t?``:`+`)}function RF(e,t=IF){let n=e.split(`+`),r=n.pop()??``,i=t?MF:PF,a=t?[...n].sort((e,t)=>NF.indexOf(e)-NF.indexOf(t)):n;return[...(zF(r)?a.filter(e=>e!==`Shift`):a).map(e=>i[e]??e),BF(r)]}function zF(e){return e.length===1&&!/[a-z0-9]/i.test(e)}function BF(e){return FF[e]||(/^(?:Key|Digit)(.)$/.exec(e)?.[1]??e).toUpperCase()}function VF(){return ue()(()=>({held:0}))}var HF=VF(),UF=ue()(()=>({ref:null,surface:`layers`}));function WF(e){return fe(UF,t=>t.surface===e?t.ref:null)}function GF(e,t){UF.setState({ref:e,surface:t})}function KF(){UF.setState({ref:null})}async function qF(e,t,n=WE,r=bD){let{page:i,frames:a}=r.getState();try{let o=await n.renameFrame(e.ref,t);i!==null&&a.includes(e.ref)&&sD(r,i,a.map(t=>t===e.ref?o.ref:t))}catch(t){ZE(`Couldn't rename ${e.name}`)(t)}}function JF(e){let{selection:t,mode:n,live:r,clipboard:i,calls:a}=e,o=()=>n.getState().mode===`edit`&&r.getState().canWrite&&!t.getState().element,s=()=>{let{page:n,frames:r}=t.getState();return n===e.page()?e.frames().filter(e=>r.includes(e.ref)):[]},c=()=>s().map(e=>e.ref),l=()=>o()&&s().length>0,u=()=>l()&&s().every(e=>!e.locked),d=n=>sD(t,e.page(),n.map(e=>e.ref)),f=e=>e.length===1?e[0]?.name??``:`${e.length} frames`,p=(e,t)=>n=>{i.setState(n),E_.add({title:`${e} ${f(t)}`,description:`Paste with ${LF(`$mod+KeyV`)} on any page.`,type:`success`})};return[{id:`frame.rename`,label:`Rename frame`,group:`frame`,command:{label:`Rename frame`,icon:On},enabled:()=>o()&&s().length===1&&!n.getState().hideUi,run:()=>{let[e]=s();e&&(n.setState({tool:`move`}),GF(e.ref,`inspector`))}},{id:`frame.duplicate`,label:`Duplicate`,group:`frame`,command:{label:`Duplicate frame`,icon:Dt},keys:[`$mod+KeyD`],enabled:l,run:()=>{let e=s();a.duplicateFrames(c()).then(d,ZE(`Couldn't duplicate ${f(e)}`))}},{id:`frame.delete`,label:`Delete`,group:`frame`,command:{label:`Delete frame`,icon:ur},keys:[`Backspace`,`Delete`],enabled:u,run:()=>{let e=s();a.deleteFrames(c()).catch(ZE(`Couldn't delete ${f(e)}`))}},{id:`frame.hide`,label:`Hide`,group:`frame`,command:{label:`Hide frame`,icon:jt},keys:[`$mod+Shift+KeyH`],enabled:l,run:()=>{let e=s();a.flagFrames(c(),`hidden`,!0).catch(ZE(`Couldn't hide ${f(e)}`))}},{id:`frame.lock`,label:`Lock`,group:`frame`,command:{label:`Lock or unlock frame`,icon:un},keys:[`$mod+Shift+KeyL`],enabled:l,checked:()=>{let e=s();return e.length>0&&e.every(e=>e.locked)},run:()=>{let e=s(),t=!e.every(e=>e.locked);a.flagFrames(c(),`locked`,t).catch(ZE(`Couldn't ${t?`lock`:`unlock`} ${f(e)}`))}},{id:`frame.copy`,label:`Copy`,group:`frame`,command:{label:`Copy frame`,icon:kt},keys:[`$mod+KeyC`],enabled:l,run:()=>{let e=s();a.copyFrames(c()).then(p(`Copied`,e),ZE(`Couldn't copy ${f(e)}`))}},{id:`frame.cut`,label:`Cut`,group:`frame`,command:{label:`Cut frame`,icon:Wn},keys:[`$mod+KeyX`],enabled:u,run:()=>{let e=s();a.cutFrames(c()).then(p(`Cut`,e),ZE(`Couldn't cut ${f(e)}`))}},{id:`frame.paste`,label:`Paste`,group:`frame`,command:{label:`Paste frames`,icon:Ct},keys:[`$mod+KeyV`],enabled:()=>o()&&i.getState().held>0,run:()=>{a.pasteFrames(e.page()).then(d,ZE(`Couldn't paste`))}}]}function YF(e,t){let n=(0,y.useRef)(e),r=(0,y.useRef)(t);(0,y.useEffect)(()=>{n.current=e,r.current=t},[e,t]),(0,y.useEffect)(()=>{let e=be(JF({page:()=>n.current,frames:()=>r.current,selection:bD,mode:iD,live:yl,clipboard:HF,calls:WE})),t=[bD.subscribe(xe),iD.subscribe(xe),HF.subscribe(xe),yl.subscribe((e,t)=>{!e.connected&&t.connected&&HF.setState({held:0}),xe()})];return()=>{for(let e of t)e();e()}},[])}var XF={phone:{width:390,height:844},tablet:{width:834,height:1194},desktop:{width:1440,height:900}},ZF=`desktop`,QF=ue()(()=>({preset:ZF}));function $F(){return fe(QF,e=>e.preset)}function eI(e){QF.setState({preset:e})}var tI=`frame`;async function nI(e,{page:t,frames:n,preset:r=QF,selection:i=bD,mode:a=iD,calls:o=WE}){let s=KE(tI,n.map(e=>e.name));try{sD(i,t,[(await o.addFrame(`${t}/${s}`,r.getState().preset,Math.round(e.x),Math.round(e.y))).ref]),a.setState({tool:`move`})}catch(e){ZE(`Couldn't add a frame`)(e)}}var rI=()=>yl.getState().canWrite;function iI(){(0,y.useEffect)(()=>{let e=be([{id:`tool.frame`,label:`Frame`,group:`tool`,command:{label:`Add a frame`,icon:Ut},keys:[`f`],enabled:rI,run:()=>iD.setState({tool:`frame`,mode:`edit`}),checked:()=>iD.getState().mode===`edit`&&iD.getState().tool===`frame`}]),t=yl.subscribe((e,t)=>{e.canWrite!==t.canWrite&&(xe(),!e.canWrite&&iD.getState().tool===`frame`&&iD.setState({tool:`move`}))});return()=>{t(),e()}},[])}function aI(){return ue()(()=>({at:null,frame:null}))}var oI=aI();function sI(e){let{place:t,selection:n,mode:r,live:i,clipboard:a,theme:o,notes:s,calls:c}=e,l=()=>r.getState().mode===`edit`,u=()=>l()&&i.getState().canWrite,d=()=>{let{page:t,frames:r}=n.getState();return t===e.page()?r:[]},f=()=>{let e=d(),n=t.getState().frame;return n&&e.includes(n)?n:e[0]},p=()=>{let e=f();return e?W_(ev(e,o)):null};return[{id:`frame.flipTheme`,get label(){let e=p();return e?`Flip to ${e}`:`Flip frame theme`},group:`frame`,command:{label:`Flip frame theme`,icon:Qn},enabled:()=>l()&&d().length>0,run:()=>{let e=p();if(e)for(let t of d())ev(t,o)!==e&&$_(t,o)}},{id:`frame.pasteAt`,label:`Paste here`,group:`frame`,enabled:()=>u()&&a.getState().held>0&&t.getState().at!==null,run:()=>{let{at:r}=t.getState();if(!r)return;let i=e.page();c.pasteFrames(i,{x:Math.round(r.x),y:Math.round(r.y)}).then(e=>sD(n,i,e.map(e=>e.ref)),ZE(`Couldn't paste`))}},{id:`frame.newAt`,label:`New frame here`,group:`frame`,enabled:()=>u()&&t.getState().at!==null,run:()=>{let{at:i}=t.getState();i&&nI(i,{page:e.page(),frames:e.frames(),preset:e.preset,selection:n,mode:r,calls:c})}},{id:`note.addHere`,label:`Add a note here`,group:`note`,enabled:()=>u()&&!!n.getState().element&&d().length>0&&t.getState().at!==null,run:()=>{let{at:i}=t.getState(),{element:a}=n.getState(),o=e.frames().find(e=>e.ref===a?.frame);if(!i||!a||!o)return;let c=e.renderedAt(o.ref);r.setState({tool:`note`}),s.setState({open:{kind:`new`,pick:{frame:{ref:o.ref,name:o.name},element:c?a.index:null,renderedAt:c,at:i}}})}}]}function cI(e,t,n){let r=(0,y.useRef)(e),i=(0,y.useRef)(t),a=(0,y.useRef)(n);(0,y.useEffect)(()=>{r.current=e,i.current=t,a.current=n},[e,t,n]),(0,y.useEffect)(()=>{let e=be(sI({page:()=>r.current,frames:()=>i.current,renderedAt:e=>a.current(e),place:oI,selection:bD,mode:iD,live:yl,clipboard:HF,theme:ov,preset:QF,notes:TP,calls:WE})),t=[oI.subscribe(xe),ov.subscribe(xe),bD.subscribe(xe),iD.subscribe(xe),HF.subscribe(xe),yl.subscribe(xe)];return()=>{for(let e of t)e();e()}},[])}var lI=y.createContext(void 0);function uI(e=!0){let t=y.useContext(lI);if(t===void 0&&!e)throw Error(Ds(25));return t}var dI=y.createContext(void 0);function fI(e){let t=y.useContext(dI);if(t===void 0&&!e)throw Error(Ds(33));return t}var pI=y.createContext(void 0);function mI(e){let t=y.useContext(pI);if(t===void 0&&!e)throw Error(Ds(36));return t}function hI({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=y.useRef(e!==void 0),[a,o]=y.useState(()=>t);return[i&&e!==void 0?e:a,y.useCallback(e=>{i||o(e)},[])]}var gI=y.createContext(null);function _I(e=`root`){let t=y.useContext(gI),n=y.useContext(pI);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var vI={visible:!0,ref:null};function yI(){return vI}function bI(e,t,n=`root`){let r=_I(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??yI)({label:e.label,children:e.children,render:e.render}),a=Is(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}function xI(e){e.preventDefault()}function SI(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=mI(),u=uI(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return y.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?xI:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:Rp})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!Ou&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&Ms(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var CI={type:`regular-item`};function wI(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=y.useRef(null),{getButtonProps:d,buttonRef:f}=Ns({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=SI({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=y.useCallback(e=>ps(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=Is(u,f);return y.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var TI=y.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function EI(){return y.useContext(TI)}function DI(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=EI(),u=y.useRef(-1),[d,f]=y.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=y.useRef(null),h=y.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return Y(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}function OI(e){return Cp(e,`base-ui`)}var kI=`data-checked`,AI=`data-unchecked`,jI={checked(e){return e?{[kI]:``}:{[AI]:``}},...Ku},MI=y.createContext(void 0);function NI(){let e=y.useContext(MI);if(e===void 0)throw Error(Ds(31));return e}var PI=y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=y.useState(void 0),c=Zs(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,G.jsx)(MI.Provider,{value:s,children:c})}),FI=y.forwardRef(function(e,t){let n=_I()?.Group??PI;return(0,G.jsx)(n,{...e,ref:t})}),II=y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=OI(a),c=NI();return Y(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Zs(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),LI=y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=mI(),f=DI({guess:!0,label:a}),p=OI(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=wI({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:CI});return Zs(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),RI=y.forwardRef(function(e,t){let n=bI(e,t);return n.visible?(0,G.jsx)(LI,{...e,ref:n.ref}):null}),zI=y.createContext(void 0);function BI(e){let t=y.useContext(zI);if(t===void 0&&!e)throw Error(Ds(69));return t}var VI=`ArrowUp`,HI=`ArrowDown`,UI=`ArrowLeft`,WI=`ArrowRight`,GI=new Set([VI,HI,UI,WI,`Home`,`End`]),KI=[`Shift`,`Control`,`Alt`,`Meta`];function qI(e){return zo(e)&&e.tagName===`INPUT`}function JI(e){return!!(qI(e)&&e.selectionStart!=null||zo(e)&&e.tagName===`TEXTAREA`)}function YI(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=XI(e,t,`left`),a=ZI(e),o=ZI(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=XI(e,t,`top`),r=ZI(e),i=ZI(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function XI(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function ZI(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}var QI=y.createContext(void 0);function $I(){return y.useContext(QI)}function eL(e,t){let n=tc(e.render);if(y.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function tL(e,t,n){let r=eL(e,t),i=r===t?void 0:r;return[r,y.useCallback(e=>n?.(e?i:void 0),[i,n])]}function nL(e,t,n){let r=tc(e.render),i=y.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var rL=y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=mI(),m=$I(),{side:h,align:g}=fI(),_=BI(!0)!=null,v=l.useState(`open`),b=l.useState(`transitionStatus`),x=l.useState(`popupProps`),S=l.useState(`mounted`),C=l.useState(`instantType`),w=l.useState(`activeTriggerElement`),T=l.useState(`parent`),E=l.useState(`lastOpenChangeReason`),D=l.useState(`rootId`),O=l.useState(`floatingRootContext`),k=l.useState(`floatingTreeRoot`),A=l.useState(`closeDelay`),j=l.useState(`hoverEnabled`),M=l.useState(`disabled`),N=l.useState(`openMethod`),P=l.useState(`activeTriggerId`),F=l.useState(`listElement`),[I,L]=tL(e,u,d),R=nL(e,w,P),z=T.type===`menu`?m:void 0,B=T.type===`context-menu`,ee=s??T.type!==`menu`;s===void 0&&F&&T.type!==`menu`&&(ee=()=>l.state.activeIndex===null&&F),Yf({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),y.useEffect(()=>{function e(e){l.setOpen(!1,jp(e.reason,e.domEvent))}return k.events.on(`close`,e),()=>{k.events.off(`close`,e)}},[k.events,l]),Fh(O,{enabled:j&&!M&&!B&&T.type!==`menubar`,closeDelay:A});let te=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:ne,handleFocus:re}=(y.useContext(gI)?.useParentHandoff??aL)(l,T,v,f),ie=Zs(`div`,e,{state:{transitionStatus:b,side:h,align:g,open:v,nested:T.type===`menu`,instant:C},ref:[t,l.context.popupRef,te,L],stateAttributesMapping:od,props:[x,{id:I,...F?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":R},onKeyDown(e){z?.onPopupKeyDown?.(e),_&&GI.has(e.key)&&e.stopPropagation()},onFocus:re},S_(b),c,{"data-rootownerid":D}]}),V=T.type===void 0||B;(w||T.type===`menubar`&&E!==`outside-press`)&&(V=!0);let H=z?.getReturnElement??ne;return(0,G.jsx)(Km,{context:O,openInteractionType:N,modal:B,disabled:!S,returnFocus:a??H??V,explicitReturnFocus:a===void 0&&H?!1:void 0,initialFocus:ee,restoreFocus:!0,getInsideElements:T.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:T.type===`menubar`?void 0:k,previousFocusableElement:w,nextFocusableElement:T.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:ie})}),iL={parentVirtualFocusRef:void 0,handleFocus:void 0};function aL(){return iL}var oL=y.forwardRef(function(e,t){let n=_I()?.Popup??rL;return(0,G.jsx)(n,{...e,ref:t})}),sL=y.createContext(void 0);function cL(){let e=y.useContext(sL);if(e===void 0)throw Error(Ds(32));return e}var lL=y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=mI();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,G.jsx)(sL.Provider,{value:n,children:(0,G.jsx)(nm,{ref:t,...r,portalOwnerRole:o})})});function uL(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=J(i),[,o]=y.useState(0),s=os(fL).current,c=os(dL).current,l=y.useRef(0),u=y.useRef(!0),d=y.useRef(null),f=y.useRef(null),p=J(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=J((e,t)=>{c.set(e,t),p()}),h=J(e=>{c.delete(e),p()}),g=J(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!hL(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&gL(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=mL(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=J(()=>{let[e,t]=pL(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});Y(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),Y(()=>{u.current&&v()}),Y(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let b=J(e=>(s.add(e),()=>{s.delete(e)})),x=y.useMemo(()=>({register:m,unregister:h,subscribeMapChange:b,nextIndexRef:l}),[m,h,b,l]);return(0,G.jsx)(TI.Provider,{value:x,children:t})}function dL(){return new Map}function fL(){return new Set}function pL(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>gL(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function mL(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function hL(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function gL(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var _L=y.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,G.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function vL(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=y.useRef(null),o=y.useRef(null),s=Jf(r);Y(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),Y(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}var yL={},bL={},xL=``;function SL(e,t){return Vo(e)?e:t}function CL(e,t,n){return/hidden|clip/.test(e.getComputedStyle(SL(t,n)).overflowY)}function wL(e){if(typeof document>`u`)return!1;let t=js(e);return Lo(t).innerWidth-t.documentElement.clientWidth>0}function TL(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=js(e),n=t.documentElement,r=t.body,i=SL(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function EL(e){let t=js(e),n=t.documentElement,r=t.body,i=SL(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function DL(e){let t=js(e),n=t.documentElement,r=t.body,i=Lo(n),a=0,o=0,s=!1,c=du.create();if(Au&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,yL={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},xL=n.style.scrollBehavior,bL={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=SL(n,r);s=TL(e),s?(n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`):(Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`)}function u(){Object.assign(n.style,yL),Object.assign(r.style,bL),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=xL)}function d(){u(),c.request(l)}l();let f=su(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var OL=new class{lockCount=0;restore=null;timeoutLock=mu.create();timeoutUnlock=mu.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=js(e),n=t.documentElement,r=t.body,i=Lo(n);if(CL(i,n,r)){let t=new i.MutationObserver(()=>{CL(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Tu||!wL(e);this.restore=a?EL(e):DL(e)}};function kL(e=!0,t=null){Y(()=>{if(e)return OL.acquire(t)},[e,t])}var AL=20;function jL(e,t,n,r){let[i,a]=y.useState(!1);Y(()=>{if(!e||!t||n==null){a(!1);return}let r=js(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-AL)},[e,t,n]),kL(e&&(!t||i),r)}var ML=y.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=tp,style:g,..._}=e,{store:v,virtualFocus:b,syncHighlightedItem:x}=mI(),S=cL(),C=uI(!0),w=v.useState(`parent`),T=v.useState(`floatingRootContext`),E=v.useState(`floatingTreeRoot`),D=v.useState(`mounted`),O=v.useState(`open`),k=v.useState(`modal`),A=v.useState(`openMethod`),j=v.useState(`activeTriggerElement`),M=v.useState(`transitionStatus`),N=v.useState(`positionerElement`),P=v.useState(`instantType`),F=v.useState(`adaptiveOrigin`),I=v.useState(`lastOpenChangeReason`),L=v.useState(`floatingNodeId`),R=v.useState(`floatingParentNodeId`),z=T.useState(`domReferenceElement`),B=n,ee=c,te=l,ne=s,re=h;w.type===`context-menu`&&(B=n??w.context?.anchor,ne??=`start`,!o&&ne!==`center`&&(te=e.alignOffset??2,ee=e.sideOffset??-5));let ie=o,V=ne;w.type===`menu`?(ie??=`inline-end`,V??=`start`,re=e.collisionAvoidance??np):w.type===`menubar`&&(ie??=w.context.orientation===`vertical`?`inline-end`:`bottom`,V??=`start`);let H=w.type===`context-menu`,ae=y_({anchor:B,floatingRootContext:T,positionMethod:C?`fixed`:r,mounted:D,side:ie,sideOffset:ee,align:V,alignOffset:te,arrowPadding:H?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:L,keepMounted:S,disableAnchorTracking:m,collisionAvoidance:re,shift:H?{crossAxis:!(`side`in re&&re.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:E,adaptiveOrigin:F,lazyFlip:b?`placement`:!1});y.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===L&&v.set(`hoverEnabled`,!1),e.nodeId!==L&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,jp(Kp)))}return E.events.on(`menuopenchange`,e),()=>{E.events.off(`menuopenchange`,e)}},[v,E.events,L]),y.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,jp(t))}return E.events.on(`menuopenchange`,e),()=>{E.events.off(`menuopenchange`,e)}},[E.events,v]);let oe=hu();y.useEffect(()=>{O||oe.clear()},[O,oe]),y.useEffect(()=>{function e(e){if(O&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&j&&j!==e.target){let e=v.select(`closeDelay`);e>0?oe.isStarted()||oe.start(e,()=>{v.setOpen(!1,jp(Kp))}):v.setOpen(!1,jp(Kp))}else oe.clear()}}return E.events.on(`itemhover`,e),()=>{E.events.off(`itemhover`,e)}},[E.events,O,j,v,oe]),y.useEffect(()=>{let e={open:O,nodeId:L,parentNodeId:R,reason:v.select(`lastOpenChangeReason`)};E.events.emit(`menuopenchange`,e)},[E.events,O,v,L,R]),vL({store:v,domReference:z,positionerElement:N,open:O});let se={open:O,side:ae.side,align:ae.align,anchorHidden:ae.anchorHidden,nested:w.type===`menu`,instant:P},U=w.type===`menubar`&&w.context.modal;jL(O&&(U||k&&I!==`trigger-hover`),A===`touch`,N,j);let ce=C_(e,se,{styles:ae.positionerStyles,transitionStatus:M,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!D,inert:!O}),le=D&&w.type!==`menu`&&(w.type!==`menubar`&&k&&I!==`trigger-hover`||w.type===`menubar`&&w.context.modal),ue=null;return w.type===`menubar`?ue=w.context.contentElement:w.type===void 0&&(ue=j),(0,G.jsxs)(dI.Provider,{value:ae,children:[le&&(0,G.jsx)(_L,{ref:w.type===`context-menu`||w.type===`nested-context-menu`?w.context.internalBackdropRef:null,inert:Bf(!O),cutout:ue}),(0,G.jsx)(Im,{id:L,children:(0,G.jsx)(uL,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:x,children:ce})})]})}),NL=y.createContext(void 0);function PL(){let e=y.useContext(NL);if(e===void 0)throw Error(Ds(34));return e}var FL=y.forwardRef(function(e,t){let{render:n,className:r,value:i,defaultValue:a,onValueChange:o,disabled:s=!1,style:c,"aria-labelledby":l,...u}=e,[d,f]=y.useState(void 0),[p,m]=hI({controlled:i,default:a,name:`MenuRadioGroup`}),h=J((e,t)=>{o?.(e,t),!t.isCanceled&&m(e)}),g=Zs(`div`,e,{state:{disabled:s},ref:t,props:{role:`group`,"aria-labelledby":l??d,"aria-disabled":s||void 0,...u}}),_=y.useMemo(()=>({value:p,setValue:h,disabled:s}),[p,h,s]);return(0,G.jsx)(MI.Provider,{value:f,children:(0,G.jsx)(NL.Provider,{value:_,children:g})})}),IL=y.memo(y.forwardRef(function(e,t){let n=_I()?.RadioGroup??FL;return(0,G.jsx)(n,{...e,ref:t})})),LL=y.createContext(void 0);function RL(){let e=y.useContext(LL);if(e===void 0)throw Error(Ds(35));return e}var zL=y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,value:l,style:u,...d}=e,{store:f}=mI(),{value:p,setValue:m,disabled:h}=PL(),g=DI({guess:!0,label:a}),_=OI(i),v=f.useState(`isActive`,g.index),b=f.useState(`floatingNodeId`),x=f.useState(`itemProps`),S=f.useState(`disabled`),C=s||h||S,w=p===l,{getItemProps:T,itemRef:E}=wI({closeOnClick:c,disabled:C,highlighted:v,id:_,store:f,nativeButton:o,nodeId:b,itemMetadata:CI}),D=y.useMemo(()=>({disabled:C,highlighted:v,checked:w}),[C,v,w]);function O(e){let t=jp(Rp,e.nativeEvent,void 0,{preventUnmountOnClose:Gs});m(l,t)}let k=Zs(`div`,e,{state:D,stateAttributesMapping:jI,props:[x,{role:`menuitemradio`,"aria-checked":w,onClick:O},d,T],ref:[E,t,g.ref]});return(0,G.jsx)(LL.Provider,{value:D,children:k})}),BL=y.forwardRef(function(e,t){let n=bI(e,t);return n.visible?(0,G.jsx)(zL,{...e,ref:n.ref}):null}),VL=y.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=RL(),c=y.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=th(s.checked);return Yf({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),Zs(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},stateAttributesMapping:jI,ref:[t,c],props:{"aria-hidden":!0,...o},enabled:a||u})}),HL=y.createContext(null);function UL(e){let t=y.useContext(HL);if(t===null&&!e)throw Error(Ds(5));return t}function WL(e){let t=y.useRef(``),n=y.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:y.useCallback(n=>{n.detail===0?e(n,`keyboard`):(`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``)},[e]),onPointerDown:n}}function GL(e,t){let n=y.useRef(e),r=J(t);Y(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function KL(e,t){let{onClick:n,onPointerDown:r}=WL(J((n,r)=>{(typeof e==`function`?e():e)||t(r||(Tu?`touch`:``))}));return y.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function qL(e){let[t,n]=y.useState(null),r=KL(e,n);return GL(e,t=>{t&&!e&&n(null)}),y.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function JL(e){return e==null?Np:e.type.startsWith(`key`)?Up:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?Wp:Np}var YL={...Eh,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=Eh.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Au&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!Eh.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},XL=class extends au{constructor(e,t,n=!1){let r=new _h,i=QL(r,t,n,e);super(i,ZL(r),YL),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function ZL(e){return{positionerRef:y.createRef(),popupRef:y.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:y.createRef(),beforeTriggerFocusGuardRef:y.createRef(),beforeContentFocusGuardRef:y.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function QL(e,t,n=!1,r){return{...bh(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:qs,inputProps:qs,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new Am,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:qs,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var $L=y.createContext(null);function eR(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function tR(e,t){return e===`list-navigation`||eR(e,t)}var nR=Yl(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:b,allowEscape:x=!0,resetOnPointerLeave:S=!0}=e,C=uI(!0),w=mI(!0),T=UL(!0),E=w?.store,D=w?.virtualFocus??!1,O=y.useMemo(()=>_&&E?{type:`menu`,store:E}:T?{type:`menubar`,context:T}:C&&!E?{type:`context-menu`,context:C}:{type:void 0},[C,E,T,_]),k=OI(),A=OI(),[j,M]=y.useState(void 0),N=(j??A)||void 0,P=Nm(),F=O.type===`menu`?O.store:void 0,I=(n??o)&&F?.state.transitionStatus===`starting`,L=os(()=>I?F?.state.instantType:void 0).current,R=os(()=>{let e=new XL({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:O,disabled:s,highlightItemOnHover:g,modal:O.type===void 0?c:void 0,rootId:k,instantType:L},N,P!=null);return e.context.virtualFocusRef=b,e}).current;R.useControlledProp(`openProp`,n),R.useControlledProp(`triggerIdProp`,m),R.useContextCallback(`onOpenChangeComplete`,i);let z=R.useState(`floatingTreeRoot`),B=Fm(z),ee=R.useState(`open`),te=R.useState(`activeTriggerElement`),ne=R.useState(`positionerElement`),re=R.useState(`hoverEnabled`),ie=R.useState(`disabled`),V=R.useState(`lastOpenChangeReason`),H=R.useState(`parent`),ae=R.useState(`activeIndex`),oe=R.useState(`keyboardOpen`),se=R.useState(`payload`),U=R.useState(`floatingParentNodeId`),ce=y.useRef(null),le=y.useRef(H.type!==`context-menu`),ue=hu(),de=y.useRef(!0),fe=hu(),pe=U!=null,{openMethod:me,triggerProps:he}=qL(ee);R.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:H.type===void 0?c:void 0,openMethod:me,rootId:k}),ph(R);let{forceUnmount:ge,transitionStatus:_e}=mh(ee,R,()=>{R.set(`allowMouseEnter`,!1)},I),ve=Jf(R.context.popupRef);y.useEffect(()=>{if(L===void 0)return;let e=()=>{R.state.instantType===L&&R.set(`instantType`,void 0)};if(!ee){e();return}if(_e!==void 0)return;if(R.context.popupRef.current==null){e();return}let t=new AbortController;return ve(e,t.signal),()=>{t.abort()}},[L,ee,_e,ve,R]),Y(()=>{C&&!w?R.update({parent:{type:`context-menu`,context:C},floatingNodeId:B,floatingParentNodeId:P}):(w||!R.select(`activeTriggerElement`))&&R.update({floatingNodeId:B,floatingParentNodeId:P})},[C,w,B,P,te,R]),y.useEffect(()=>{ee||(ce.current=null),H.type===`context-menu`&&(ee?ue.start(500,()=>{le.current=!0}):(ue.clear(),le.current=!1))},[ue,ee,H.type]),Y(()=>{!ee&&!re&&R.set(`hoverEnabled`,!0)},[ee,re,R]);let ye=J((e,t)=>{let n=t.reason;if(!e&&!R.select(`open`)||ee===e&&t.trigger===te&&V===n)return;let i=uh(t);if(!e&&t.trigger==null&&(t.trigger=te??void 0),r?.(e,t),t.isCanceled)return;R.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!de.current)return;e&&n===`trigger-focus`?(de.current=!1,fe.start(300,()=>{de.current=!0})):(de.current=!0,fe.clear());let o=!e&&(n===`escape-key`||n==null);ce.current=t.event;let s=lh(R.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&tR(n,a),s.instantType=H.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:eR(n,a)?`click`:o?`dismiss`:void 0,R.update(s)}),be=eh({popupStore:R,floatingRootContext:R.state.floatingRootContext,floatingId:N,nested:P!=null,onOpenChange:ye}),xe=be.context.events;Y(()=>{let e=({open:e,eventDetails:t})=>ye(e,t);return xe.on(`setOpen`,e),()=>{xe?.off(`setOpen`,e)}},[xe,ye]),Y(()=>R.subscribeToParentMenu(),[R]);let Se=y.useCallback(()=>{R.setOpen(!1,jp(Xp))},[R]);y.useImperativeHandle(d,()=>({unmount:ge,close:Se}),[ge,Se]);let Ce;H.type===`context-menu`&&(Ce=H.context),y.useImperativeHandle(Ce?.positionerRef,()=>ne,[ne]),y.useImperativeHandle(Ce?.actionsRef,()=>({setOpen:ye}),[ye]);let we=$m(be,{enabled:!ie,bubbles:{escapeKey:f&&H.type===`menu`},outsidePress(){return H.type!==`context-menu`||ce.current?.type===`contextmenu`||le.current},externalTree:pe?z:void 0}),Te=a_(),Ee=Wh(be,{enabled:!ie,listRef:R.context.itemDomElements,activeIndex:ae,virtual:v,nested:H.type===`menubar`||!v&&H.type!==void 0,parentOrientation:H.type===`menubar`?H.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?oe:void 0,allowEscape:v&&l&&x,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Te===`rtl`,disabledIndices:Ks,onNavigate(e,t){R.setActiveIndex(e,JL(t),t?.nativeEvent)},openOnArrowKeyDown:H.type!==`context-menu`&&!(v&&_),externalTree:!v&&pe?z:void 0,nestedReturnFocusRef:F?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:S}),De=y.useCallback(e=>{R.context.typingRef.current=e},[R]),Oe=Gh(be,{enabled:!ie&&!v,listRef:R.context.itemLabels,elementsRef:R.context.itemDomElements,activeIndex:ae,resetMs:500,onMatch:(e,t)=>{ee&&e!==ae&&R.setActiveIndex(e,Up,t.nativeEvent)},onTyping:De}),ke=J(a),Ae=y.useRef(-1),je=J(()=>{let e=R.state.activeIndex,t=e===null?void 0:R.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Ae.current===n&&R.context.reportedItem===t)return;Ae.current=n,R.context.reportedItem=t,v&&R.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=R.context;R.context.highlightReason=Np,R.context.highlightEvent=void 0,a&&ke(t,Mp(r,i,{label:t===void 0?void 0:R.context.itemLabels.current[n]??void 0}))});Y(()=>{je()},[ae,je]);let Me=y.useMemo(()=>{if(!v)return Ee.reference;if(!Ee.trigger)return qs;let{onFocus:e,...t}=Ee.trigger;return t},[v,Ee.reference,Ee.trigger]);R.useSyncedValue(`inputProps`,v?Ee.reference??qs:qs);let Ne=y.useMemo(()=>{let e=ps(Oe.reference,Me,we.reference,{onMouseMove(){R.set(`allowMouseEnter`,!0)}},he);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=ee,e},[R,Oe.reference,Me,we.reference,he,ee]),Pe=y.useMemo(()=>{let e=ps(Ee.trigger,we.trigger,he);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Ee.trigger,we.trigger,he]);os(()=>(R.update({inactiveTriggerProps:Pe}),null)),hh(R,{floatingRootContext:be,activeTriggerProps:Ne,inactiveTriggerProps:Pe,popupProps:y.useMemo(()=>ps(rh,{onMouseMove(){R.set(`allowMouseEnter`,!0),H.type===`menu`&&R.set(`hoverEnabled`,!1)},onClick(){R.select(`hoverEnabled`)&&R.set(`hoverEnabled`,!1)},onKeyDown(e){let t=R.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Oe.floating,Ee.floating,we.floating),[H.type,R,Oe.floating,Ee.floating,we.floating]),itemProps:Ee.item??qs});let Fe=y.useMemo(()=>({store:R,parent:O,orientation:u,loopFocus:l,allowEscape:x,defaultFloatingId:A,setRenderedFloatingId:M,virtualFocus:v,parentVirtualFocus:D,syncHighlightedItem:je}),[R,O,u,l,x,A,v,D,je]),Ie=typeof t==`function`?t({payload:se}):t,Le=(0,G.jsxs)(pI.Provider,{value:Fe,children:[p&&(0,G.jsx)(oh,{handle:p,store:R}),Ie]});return(H.type===void 0||H.type===`context-menu`)&&(Le=(0,G.jsx)(Lm,{externalTree:z,children:Le})),Le});function rR(e){let t=y.useContext($L);if(t===null)return(0,G.jsx)(nR,{...e});let n=t.Root;return(0,G.jsx)($L.Provider,{value:null,children:(0,G.jsx)(n,{...t.options,...e})})}var iR={};function aR(e){mI();let t=y.useContext($L);if(t!==null){let n=t.SubmenuRoot;return(0,G.jsx)($L.Provider,{value:null,children:(0,G.jsx)(n,{...t.options,...e})})}return(0,G.jsx)(QI.Provider,{value:iR,children:(0,G.jsx)(nR,{...e,isSubmenu:!0})})}var oR=5;function sR(e,t){let n=cR(t);return e.clientX>=n.left-oR&&e.clientX<=n.right+oR&&e.clientY>=n.top-oR&&e.clientY<=n.bottom+oR}function cR(e){let t=e.getBoundingClientRect(),n=Lo(e);if(Mu)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function lR(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=ks(),{ref:i,index:a}=DI(e),o=n===a,s=y.useRef(null),c=Is(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function uR(e){let{render:t,className:n,style:r,state:i=qs,props:a=Ks,refs:o=Ks,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=lR({metadata:s});return Zs(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function dR(e){if(zo(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Zo(e))return dR(es(e))}function fR(e,t){function n(n,r,i){let a=n.currentTarget;Gf.flushSync(()=>{e.setOpen(!1,jp(Bp,n.nativeEvent,a))}),Tf(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&Ef(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function pR(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=y.useRef(!1);return y.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,js(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:qs,[t,n,r])}var mR=Xl(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=mI(!0),h=Dh(d)??m?.store;if(!h)throw Error(Ds(85));let g=OI(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),b=h.useState(`isOpenedByTrigger`,g),x=h.useState(`triggerControlsId`,g),S=y.useRef(null),C=gR(),w=ks(!0),T=Pm(),E=y.useMemo(()=>T??new Am,[T]),{registerTrigger:D,isMountedByThisTrigger:O}=fh(g,S,h,{payload:f,closeDelay:u,parent:C,floatingTreeRoot:E,floatingNodeId:Fm(E),floatingParentNodeId:Nm(),keyboardEventRelay:w?.relayKeyboardEvent}),k=C.type===`menubar`,A=h.useState(`disabled`),j=a||A||k&&C.context.disabled,{getButtonProps:M,buttonRef:N}=Ns({disabled:j,native:o});y.useEffect(()=>{!b&&C.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,b,C.type]);let P=y.useRef(null),F=hu(),I=J(e=>{if(!P.current)return;F.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Q(P.current,t)||Q(h.select(`positionerElement`),t)||t===P.current||(t==null||dR(t)!==h.select(`rootId`))&&(sR(e,P.current)||E.events.emit(`close`,{domEvent:e,reason:Gp}))});y.useEffect(()=>{let e=js(P.current);if(b&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,I,{once:!0}),()=>{e.removeEventListener(`mouseup`,I)}},[b,I,h]);let L=k&&C.context.hasSubmenuOpen,R=Lh(v,{enabled:(c??L)&&!j&&(!k||L&&!O),handleClose:$h({blockPointerEvents:!k}),mouseOnly:!0,move:!1,restMs:C.type===void 0?l:void 0,delay:{close:u},triggerElementRef:S,externalTree:E,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),z=hR(b,h.select(`lastOpenChangeReason`)),B=qm(v,{enabled:!j,event:b&&k?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:C.type===void 0&&z}),ee=kh(v,{enabled:!j&&L}),te=pR({open:b,enabled:k,mouseDownAction:`open`}),ne=y.useMemo(()=>ps(ee.reference,B.reference),[ee.reference,B.reference]),re=h.useState(`triggerProps`,O),ie=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:V,handleFocusTargetFocus:H}=fR(h,S),ae={disabled:j,open:b},oe=[P,t,N,D,S],se=[ne,R??qs,re,{"aria-haspopup":`menu`,"aria-controls":x,id:g,onMouseDown:e=>{h.select(`open`)||(F.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),js(e.currentTarget).addEventListener(`mouseup`,I,{once:!0}))}},ie,k?{role:`menuitem`}:{},te,p,M],U=Zs(`button`,e,{enabled:!k,stateAttributesMapping:id,state:ae,ref:oe,props:se});return k?(0,G.jsx)(uR,{tag:`button`,render:n,className:r,style:i,state:ae,refs:oe,props:se,stateAttributesMapping:id}):b?(0,G.jsxs)(y.Fragment,{children:[(0,G.jsx)(Lf,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:V},`${g}-pre-focus-guard`),(0,G.jsx)(y.Fragment,{children:U},g),(0,G.jsx)(Lf,{ref:h.context.triggerFocusTargetRef,onFocus:H},`${g}-post-focus-guard`)]}):(0,G.jsx)(y.Fragment,{children:U},g)});function hR(e,t){let n=hu(),[r,i]=y.useState(!1);return Y(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function gR(){let e=UL(!0);return y.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var _R=y.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Zs(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function vR(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var yR={"aria-expanded":void 0},bR=y.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:l=100,closeDelay:u=0,disabled:d=!1,...f}=e,p=mI(!0);if(p?.parent.type!==`menu`)throw Error(Ds(37));let m=fI(),h=$I(),{store:g,parentVirtualFocus:_}=p,v=p.parent.store,b=DI({guess:!0,label:a}),x=OI(o),S=g.useState(`open`),C=y.useRef(!1),w=g.useState(`positionerElement`),T=g.useState(`floatingRootContext`),E=g.useState(`floatingTreeRoot`),D=g.useState(`triggerPopupId`,x),O=ch(x,g),k=J(e=>{O(e);let t=g.select(`activeTriggerElement`);e!==null&&g.select(`open`)&&(t===e||g.select(`activeTriggerId`)==null)&&g.update({activeTriggerId:x??null,activeTriggerElement:e,closeDelay:u})}),A=y.useRef(null),j=y.useCallback(e=>{A.current=e,g.set(`activeTriggerElement`,e)},[g]);Y(()=>(k(A.current),()=>k(null)),[k,x,g]),Y(()=>{if(!S||!w)return;function e(e){Fu(e)===g.context.beforeContentFocusGuardRef.current&&(C.current=e.relatedTarget===A.current)}return w.addEventListener(`focusout`,e,!0),()=>{C.current=!1,w.removeEventListener(`focusout`,e,!0)}},[S,w,g]),g.useSyncedValue(`closeDelay`,u);let M=g.useState(`disabled`),N=v.useState(`disabled`),P=d||M||N,F=v.useState(`itemProps`),I=v.useState(`isActive`,b.index),L=y.useMemo(()=>({type:`submenu-trigger`,setActive(e){v.select(`highlightItemOnHover`)&&v.setActiveIndex(b.index,Wp,e)}}),[v,b.index]),{getItemProps:R,itemRef:z}=wI({closeOnClick:!1,disabled:P,highlighted:I,id:x,store:g,typingRef:v.context.typingRef,nativeButton:s,itemMetadata:L,nodeId:m?.context.nodeId}),B=Lh(T,{enabled:g.useState(`hoverEnabled`)&&c&&!P,handleClose:$h({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>v.select(`allowMouseEnter`):void 0,triggerElementRef:A,externalTree:E,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),ee=qm(T,{enabled:!P,event:`mousedown`,toggle:!0,ignoreMouse:c,stickIfOpen:c}).reference??qs,te=g.useState(`triggerProps`,!0);delete te.id;let ne={disabled:P,highlighted:I,open:S},re=g.useState(`openMethod`),ie=g.useState(`lastOpenChangeReason`)===`list-navigation`||re===`keyboard`,V=S&&ie&&ju;return Zs(`div`,e,{state:ne,stateAttributesMapping:rd,props:[ee,B,te,h?.onTriggerKeyDown?{onKeyDown:h.onTriggerKeyDown}:void 0,F,V?yR:void 0,{"aria-controls":D,tabIndex:_||!(S||I)?-1:0,onFocus(e){g.select(`open`)&&C.current&&(C.current=!1,g.setOpen(!1,jp(Bp,e.nativeEvent)))},onBlur(){I&&v.setActiveIndex(null,Np)}},f,R],ref:[t,b.ref,z,k,j]})}),xR=y.forwardRef(function(e,t){let n=bI(e,t,`submenu-trigger`);if(!n.visible)return null;let r=n.props?ps(n.props,e):e;return(0,G.jsx)(bR,{...r,ref:n.ref})});function SR(e){let[t,n]=y.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=y.useRef(null),i=y.useRef(null),a=y.useRef(null),o=y.useRef(null),s=y.useRef(!0),c=y.useRef(null),l=Cp(),u=y.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:l}),[t,l]);return(0,G.jsx)(lI.Provider,{value:u,children:(0,G.jsx)(pI.Provider,{value:void 0,children:(0,G.jsx)(rR,{...e})})})}var CR=500,wR=y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:l,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:f,rootId:p}=uI(!1),{store:m}=mI(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=y.useRef(null),v=y.useRef(null),b=hu(),x=hu(),S=y.useRef(!1),C=y.useRef(null);function w(e,t,n){let r=n.type.startsWith(`touch`);f.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),S.current=!1,s.current?.setOpen(!0,jp(Pp,n)),x.start(CR,()=>{S.current=!0})}function T(e){if(g)return;d.current=!0,vd(e),w(e.clientX,e.clientY,e.nativeEvent);let t=js(_.current);C.current?.abort();let n=new AbortController;C.current=n,t.addEventListener(`mouseup`,e=>{if(d.current=!1,!S.current)return;x.clear(),S.current=!1;let t=Fu(e);Q(u.current,t)||p&&t&&dR(t)===p||s.current?.setOpen(!1,jp(Gp,e))},{once:!0,signal:n.signal})}function E(){b.clear(),v.current=null}function D(e){if(g||(d.current=!1,e.touches.length!==1)){E();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};v.current=n,b.start(CR,()=>{w(n.x,n.y,e.nativeEvent)})}function O(e){if(e.touches.length!==1)E();else if(b.isStarted()&&v.current){let t=e.touches[0],n=Math.abs(t.clientX-v.current.x),r=Math.abs(t.clientY-v.current.y);(n>10||r>10)&&E()}}return y.useEffect(()=>()=>{C.current?.abort()},[]),y.useEffect(()=>{function e(e){if(g)return;let t=Fu(e);(Q(_.current,t)||Q(c.current,t)||Q(l.current,t))&&e.preventDefault()}return su(js(_.current),`contextmenu`,e)},[l,g,c]),Zs(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:T,onTouchStart:D,onTouchMove:O,onTouchEnd:E,onTouchCancel:E,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:id})}),TR=ML;function ER({...e}){return(0,G.jsx)(SR,{"data-slot":`context-menu`,...e})}function DR({className:e,...t}){return(0,G.jsx)(wR,{"data-slot":`context-menu-trigger`,className:X(`select-none`,e),...t})}function OR({className:e,align:t=`start`,alignOffset:n=4,side:r=`right`,sideOffset:i=0,...a}){return(0,G.jsx)(lL,{children:(0,G.jsx)(TR,{className:`isolate z-50 outline-none`,align:t,alignOffset:n,side:r,sideOffset:i,children:(0,G.jsx)(oL,{"data-slot":`context-menu-content`,className:X(`z-50 max-h-(--available-height) w-50 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-[10px] bg-popover p-1 text-xs text-popover-foreground shadow-[0_12px_40px_rgba(0,0,0,.3)] ring-1 ring-border duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...a})})})}function kR({...e}){return(0,G.jsx)(FI,{"data-slot":`context-menu-group`,...e})}function AR({className:e,inset:t,...n}){return(0,G.jsx)(II,{"data-slot":`context-menu-label`,"data-inset":t,className:X(`px-2 pt-1.5 pb-1 text-[11px] font-semibold text-faint data-inset:pl-7`,e),...n})}function jR({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(RI,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:X(`group/context-menu-item relative flex h-7 cursor-default items-center gap-1.5 rounded-md px-2 py-0 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function MR({className:e,...t}){return(0,G.jsx)(_R,{"data-slot":`context-menu-separator`,className:X(`my-1 h-px bg-border`,e),...t})}function NR({className:e,...t}){return(0,G.jsx)(`kbd`,{"data-slot":`context-menu-shortcut`,className:X(`ml-auto grid h-5 min-w-5 place-items-center rounded-[5px] bg-muted px-[5px] font-sans text-[11px] font-normal text-muted-foreground`,e),...t})}function PR({action:e,children:t,binding:n,chips:r,keyName:i,variant:a}){let o=n??e?.keys?.[0],s=r??(o?RF(o):[]);return(0,G.jsxs)(jR,{variant:a,disabled:!e||!Se(e),"aria-keyshortcuts":i,onClick:()=>e?.run(),children:[t??e?.label,s.length>0?(0,G.jsx)(`span`,{"aria-hidden":!0,className:`ml-auto flex gap-[3px]`,children:s.map((e,t)=>(0,G.jsx)(`kbd`,{className:`grid h-5 min-w-5 place-items-center rounded-[5px] bg-muted px-[5px] font-sans text-[11px] font-normal text-muted-foreground`,children:e},t))}):null]})}function FR({action:e}){return(0,G.jsx)(PR,{action:e,chips:[`⌫`],keyName:`Delete`,variant:`destructive`,children:`Delete`})}function IR({children:e}){return(0,G.jsx)(AR,{children:e})}function LR(e,t,n,r){let i=r?e.find(e=>e.ref===r.frame&&!e.hidden):void 0;if(r&&i&&RR(r.box,t))return{kind:`element`,frame:i,at:t};let a=vF(e,t,n);return a?{kind:`frame`,frame:a,at:t}:{kind:`canvas`,at:t}}function RR(e,{x:t,y:n}){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}var zR={frame:`w-55`,element:`w-[230px]`,canvas:`w-[210px]`};function BR({page:e,frames:t,viewport:n,layer:r,trigger:i}){let[a,o]=(0,y.useState)(null),s=e=>{let i=n.current,a=r.current;if(!i||!a)return null;let o=sN(i),[s,c]=o.invert(Vk(e,i)),{element:l}=bD.getState(),u=l?_F(a):null;return LR(t(),{x:s,y:c},o.k,l&&u?{frame:l.frame,box:u}:null)};return(0,G.jsxs)(ER,{onOpenChangeComplete:e=>{e||oI.setState({at:null,frame:null})},children:[(0,G.jsx)(DR,{render:i,onContextMenu:t=>{let n=t.nativeEvent.defaultPrevented?null:s(t.nativeEvent);if(!n)t.preventBaseUIHandler();else{if(n.kind===`frame`){let{frames:t,element:r}=bD.getState();(r||!t.includes(n.frame.ref))&&sD(bD,e,[n.frame.ref])}oI.setState({at:n.at,frame:n.kind===`canvas`?null:n.frame.ref}),o(n)}}}),(0,G.jsxs)(OR,{className:a?zR[a.kind]:void 0,children:[a?.kind===`frame`?(0,G.jsx)(HR,{}):null,a?.kind===`element`?(0,G.jsx)(WR,{noteable:!0}):null,a?.kind===`canvas`?(0,G.jsx)(KR,{}):null]})]})}var VR=[`frame.copyPng`,`frame.duplicate`,`frame.rename`,`frame.hide`,`frame.lock`,`frame.flipTheme`,`frame.delete`];function HR(){let[e,t,n,r,i,a,o]=Ce(VR);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(kR,{children:[(0,G.jsx)(PR,{action:e,children:`Copy as PNG`}),(0,G.jsx)(PR,{action:t,children:`Duplicate`}),(0,G.jsx)(PR,{action:n,children:`Rename`})]}),(0,G.jsx)(MR,{}),(0,G.jsxs)(kR,{children:[(0,G.jsx)(PR,{action:r,children:`Hide`}),(0,G.jsx)(PR,{action:i,children:i?.checked?.()?`Unlock`:`Lock`}),(0,G.jsx)(PR,{action:a})]}),(0,G.jsx)(MR,{}),(0,G.jsx)(FR,{action:o})]})}var UR=[`note.addHere`,`tool.note`,`element.up`,`view.zoomToSelection`,`frame.copyPng`];function WR({noteable:e}){let[t,n,r,i,a]=Ce(UR),o=xD(e=>e.element??null),s=o?NP(o.frame):null,c=o&&s?RP(s.elements,o.index)===null:!0;return(0,G.jsxs)(kR,{children:[(0,G.jsx)(IR,{children:`Element`}),e?(0,G.jsx)(PR,{action:t,binding:n?.keys?.[0],children:`Add a note here`}):null,(0,G.jsx)(PR,{action:r,children:c?`Select frame`:`Select parent`}),(0,G.jsx)(PR,{action:i,children:`Zoom to selection`}),(0,G.jsx)(MR,{}),(0,G.jsx)(PR,{action:a,children:`Copy frame as PNG`})]})}var GR=[`frame.pasteAt`,`frame.paste`,`frame.newAt`,`tool.frame`,`selection.all`,`view.zoomToFit`,`view.hideUi`];function KR(){let[e,t,n,r,i,a,o]=Ce(GR);return(0,G.jsxs)(kR,{children:[(0,G.jsx)(IR,{children:`Empty canvas`}),(0,G.jsx)(PR,{action:e,binding:t?.keys?.[0],children:`Paste here`}),(0,G.jsx)(PR,{action:n,binding:r?.keys?.[0],children:`New frame here`}),(0,G.jsx)(MR,{}),(0,G.jsx)(PR,{action:i,children:`Select all`}),(0,G.jsx)(PR,{action:a,children:`Zoom to fit`}),(0,G.jsx)(PR,{action:o,children:`Hide UI`})]})}function qR(e,t){return t&&e.some(e=>e.session===t)?t:e.length===1?e[0]?.session??``:``}function JR(e){if(e instanceof jl){if(e.code===`stale-address`)return`The frame changed since it was clicked. Click the element again.`;if(e.code===`unauthorized`)return`This tab cannot write. Open the board through frameboard serve.`;if(e.code===`notes-invalid`)return`This page's notes.json does not read. Fix it by hand and try again.`}return`The note did not save. Try again.`}function YR({listeners:e}){return(0,G.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5 font-normal text-muted-foreground`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-claim`}),e.length===0?`No session listening`:`${e.length} listening`]})}function XR({listeners:e,value:t,onChange:n,disabled:r}){let i=e.length===0;return(0,G.jsxs)(`label`,{className:`relative flex h-[26px] min-w-0 items-center gap-1.5 rounded-md bg-muted pr-6 pl-2 text-foreground has-[select:disabled]:opacity-60 has-[select:focus-visible]:ring-3 has-[select:focus-visible]:ring-ring/50`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`size-[7px] shrink-0 rounded-full bg-claim`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Send to`}),(0,G.jsxs)(`select`,{value:t,disabled:r||i,onChange:e=>n(e.target.value),className:`min-w-0 appearance-none truncate bg-transparent outline-none disabled:cursor-not-allowed`,children:[i?(0,G.jsx)(`option`,{value:``,children:`No session`}):null,!i&&e.length>1?(0,G.jsx)(`option`,{value:``,disabled:!0,children:`Pick a session`}):null,e.map(e=>(0,G.jsx)(`option`,{value:e.session,children:e.tag},e.session))]}),(0,G.jsx)(dt,{"aria-hidden":!0,className:`pointer-events-none absolute right-2 size-2.5 text-muted-foreground`})]})}function ZR({pick:e,onClose:t}){let n=Z(e=>e.listeners),r=Z(t=>t.claims[e.frame.ref]?.session),i=Z(e=>e.canWrite),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(()=>qR(n,r)),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(!1),p=n.some(e=>e.session===s)?s:qR(n,r),m=async n=>{if(a.trim()===``)u(`Write the note first`);else if(n===``)u(`Pick a session to send it to`);else{f(!0);try{await Ml(`/api/notes`,{frame:e.frame.ref,text:a.trim(),...e.element===null?{}:{element:e.element,renderedAt:e.renderedAt},...n===null?{}:{to:n}}),t()}catch(e){u(JR(e))}finally{f(!1)}}};return(0,G.jsx)(QR,{title:`New note on ${e.frame.name}`,listeners:n,onClose:t,children:(0,G.jsxs)(`form`,{className:`m-3 rounded-lg border border-border p-2`,onSubmit:e=>{e.preventDefault(),m(p)},children:[(0,G.jsx)(`textarea`,{"aria-label":`Note on ${e.frame.name}`,autoFocus:!0,value:a,disabled:!i,onChange:e=>{o(e.target.value),u(null)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&e.currentTarget.form?.requestSubmit()},rows:2,className:`block min-h-7 w-full resize-none bg-transparent text-foreground outline-none placeholder:text-faint disabled:cursor-not-allowed`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(XR,{listeners:n,value:p,onChange:e=>{c(e),u(null)},disabled:!i}),(0,G.jsx)($R,{variant:`ghost`,className:`ml-auto`,disabled:!i||d,onClick:()=>void m(null),children:`Save`}),(0,G.jsx)($R,{type:`submit`,variant:`primary`,disabled:!i||d||n.length===0,children:`Send`})]}),l?(0,G.jsx)(`p`,{role:`alert`,className:`mt-2 text-destructive`,children:l}):null]})})}function QR({title:e,listeners:t,onClose:n,children:r}){return(0,G.jsxs)(`section`,{"aria-label":e,"data-note-card":!0,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),n())},onPointerDown:e=>e.stopPropagation(),onWheel:e=>e.stopPropagation(),className:`pointer-events-auto w-[300px] overflow-hidden rounded-xl border border-border bg-card text-body text-card-foreground shadow-[0_12px_40px_rgba(0,0,0,.3)]`,children:[(0,G.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border px-3 py-2.5 font-semibold`,children:[(0,G.jsx)(`h2`,{className:`truncate`,children:e}),(0,G.jsx)(YR,{listeners:t})]}),r]})}function $R({variant:e,className:t,type:n=`button`,...r}){return(0,G.jsx)(`button`,{type:n,className:X(`flex h-[26px] shrink-0 items-center rounded-lg px-3 font-medium outline-none focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50`,e===`primary`?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-foreground hover:bg-accent`,t),...r})}function ez(e){return e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()).join(``)}var tz,nz=!1,rz=new Set;function iz(){return(0,y.useSyncExternalStore)(az,()=>tz)}function az(e){return rz.add(e),nz||(nz=!0,fetch(`/api/author`).then(e=>e.json()).then(e=>e.ok?e.data.name:null).catch(()=>null).then(e=>{tz=e;for(let e of rz)e()})),()=>{rz.delete(e)}}function oz({notes:e,page:t,onClose:n}){let r=Z(e=>e.listeners),i=Z(n=>t?n.claims[`${t}/${e[0]?.frame}`]?.session:void 0),a=Z(e=>e.canWrite),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(()=>qR(r,i)),[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(!1),m=e[0];if(!m)return null;let h=r.some(e=>e.session===c)?c:qR(r,i),g=async(e,t)=>{p(!0);try{await e(),t?.()}catch(e){d(JR(e))}finally{p(!1)}},_=()=>{let e=o.trim();e===``&&h===``?d(r.length>1?`Pick a session to send it to`:`Write a reply first`):e===``?g(()=>Ml(`/api/notes/${m.id}/send`,{to:h})):g(()=>Ml(`/api/notes/${m.id}/replies`,{text:e,...h===``?{}:{to:h}}),()=>s(``))};return(0,G.jsxs)(QR,{title:`Note ${m.number??``}`.trim(),listeners:r,onClose:n,children:[(0,G.jsx)(`ol`,{"aria-label":`Messages`,children:e.map(e=>(0,G.jsx)(sz,{note:e},e.id))}),(0,G.jsxs)(`form`,{className:`mx-3 mt-1.5 mb-3 rounded-lg border border-border p-2`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,G.jsx)(`textarea`,{"aria-label":`Reply`,placeholder:`Reply, or hand it on…`,value:o,disabled:!a,onChange:e=>{s(e.target.value),d(null)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&e.currentTarget.form?.requestSubmit()},rows:1,className:`block min-h-7 w-full resize-none bg-transparent text-foreground outline-none placeholder:text-faint disabled:cursor-not-allowed`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(XR,{listeners:r,value:h,onChange:e=>{l(e),d(null)},disabled:!a}),(0,G.jsx)($R,{variant:`ghost`,className:`ml-auto`,disabled:!a||f,onClick:()=>void g(()=>Ml(`/api/notes/${m.id}/done`,{}),n),children:`Done`}),(0,G.jsx)($R,{type:`submit`,variant:`primary`,disabled:!a||f,children:`Send`})]}),u?(0,G.jsx)(`p`,{role:`alert`,className:`mt-2 text-destructive`,children:u}):null]})]})}function sz({note:e}){let t=iz(),n=e.from===`agent`;return(0,G.jsxs)(`li`,{className:`flex gap-2.5 px-3 py-2.5`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:X(`grid size-[22px] flex-none place-items-center rounded-full text-[10px] font-bold`,n?`bg-claim/25 text-claim`:`bg-foreground text-card`),children:n?`C`:ez(e.author??t??``)||`Y`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`b`,{className:`font-semibold`,children:n?`claude`:`You`}),(0,G.jsx)(`time`,{dateTime:e.createdAt,className:`ml-1.5 text-faint`,children:cz(e.createdAt)}),(0,G.jsx)(`p`,{className:`mt-0.5 leading-[1.45] break-words whitespace-pre-wrap`,children:e.text})]})]})}function cz(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.getHours()%12||12}:${String(t.getMinutes()).padStart(2,`0`)}`}function lz({page:e,frames:t,container:n}){let r=Z(t=>t.notes[e]),i=aD(e=>e.mode===`play`),a=EP(e=>e.open);if(gz(n),hz(a!==null),i)return null;let o=(r??[]).filter(e=>e.thread===null&&e.state!==`done`),s=new Map(t.map(e=>[e.name,e])),c=e=>{let t=s.get(e.frame);return t?mz(t,e.element,n):null},l=Math.max(0,...(r??[]).map(e=>e.number??0))+1,u=a?.kind===`thread`&&a.page===e?(r??[]).filter(e=>e.id===a.id||e.thread===a.id):null,d=u?.[0],f=d?c(d):null;return(0,G.jsxs)(G.Fragment,{children:[o.map(t=>{let n=c(t);return!n||t.number===null?null:(0,G.jsx)(uz,{number:t.number,at:n,active:a?.kind===`thread`&&a.id===t.id,label:`Note ${t.number} on ${t.frame}`,onOpen:()=>TP.setState({open:{kind:`thread`,page:e,id:t.id}})},t.id)}),a?.kind===`new`&&t.some(e=>e.ref===a.pick.frame.ref)?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(uz,{number:l,at:a.pick.at,active:!0}),(0,G.jsx)(pz,{at:a.pick.at,children:(0,G.jsx)(ZR,{pick:a.pick,onClose:DP},a.pick.frame.ref)})]}):null,u&&f?(0,G.jsx)(pz,{at:f,children:(0,G.jsx)(oz,{notes:u,page:e,onClose:DP})}):null]})}function uz({number:e,at:t,active:n,label:r,onOpen:i}){let a=X(`pointer-events-auto absolute grid size-[22px] place-items-center rounded-[11px_11px_11px_2px] bg-note text-label font-semibold text-[#1a1a1a] shadow-[0_2px_6px_rgba(0,0,0,.25)] outline-none [transform:translate(-50%,-50%)_scale(calc(1/var(--zoom,1)))] focus-visible:ring-3 focus-visible:ring-ring/50`,n&&`shadow-[0_0_0_3px_color-mix(in_srgb,var(--note)_35%,transparent),0_2px_6px_rgba(0,0,0,.25)]`),o={left:t.x,top:t.y};return i?(0,G.jsx)(`button`,{type:`button`,"data-note-marker":!0,"aria-label":r,"aria-expanded":n,onPointerDown:e=>e.stopPropagation(),onClick:i,className:a,style:o,children:e}):(0,G.jsx)(`span`,{"aria-hidden":!0,className:a,style:o,children:e})}var dz={x:21,y:-25},fz=12;function pz({at:e,children:t}){let n=(0,y.useRef)(null),[r,i]=(0,y.useState)({flip:!1,y:0});return(0,y.useLayoutEffect)(()=>{let e=n.current,t=e?.closest(`[data-canvas]`);if(!e||!t)return;let a=t.getBoundingClientRect(),o=e.getBoundingClientRect(),s=r.flip?o.right+o.width+2*dz.x:o.right,c=o.top-r.y,l={flip:s>a.right-fz,y:c<a.top+fz?a.top+fz-c:Math.min(0,a.bottom-fz-(c+o.height))};(l.flip!==r.flip||Math.abs(l.y-r.y)>.5)&&i(l)},[e.x,e.y,r]),(0,G.jsx)(`div`,{className:`absolute origin-top-left [transform:scale(calc(1/var(--zoom,1)))]`,style:{left:e.x,top:e.y},children:(0,G.jsx)(`div`,{ref:n,className:`absolute`,style:{top:dz.y+r.y,...r.flip?{right:dz.x}:{left:dz.x}},children:t})})}function mz(e,t,n){let{x:r,y:i,width:a}=e.box,o=t===null?null:n?.querySelector(`[data-frame="${CSS.escape(e.ref)}"] iframe`)?.contentDocument,s=o&&t!==null?BN(o,t):null;if(!s)return{x:r+a,y:i};let c=s.getBoundingClientRect();return{x:r+Math.min(c.right,a),y:i+Math.max(c.top,0)}}function hz(e){(0,y.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&DP()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function gz(e){let[,t]=(0,y.useState)(0);(0,y.useEffect)(()=>{if(!e)return;let n=()=>t(e=>e+1);return e.addEventListener(`load`,n,!0),()=>e.removeEventListener(`load`,n,!0)},[e])}var _z=[.02,4],vz=64,yz=150,bz=400,xz=new Map;function Sz({page:e,reloads:t,findings:n,claims:r,focus:i,onFocused:a}){let o=(0,y.useRef)(null),s=(0,y.useRef)(null),c=(0,y.useRef)(null),l=(0,y.useRef)(null),[u,d]=(0,y.useState)(null),f=(0,y.useRef)(null),p=(0,y.useRef)(0),m=aD(e=>e.mode===`play`),h=aD(e=>e.tool===`hand`),g=aD(e=>e.tool===`note`),_=aD(e=>e.tool===`frame`);kP();let v=jN(e=>e.unseen),[b,x]=(0,y.useState)(null),S=(0,y.useMemo)(()=>e.frames.filter(e=>!e.hidden),[e.frames]),C=(0,y.useRef)(S);(0,y.useLayoutEffect)(()=>{C.current=S},[S]),HP(e.ref),dF(e.ref,S),cI(e.ref,e.frames,e=>s.current?.querySelector(`[data-frame="${CSS.escape(e)}"] iframe`)?.dataset.renderedAt??null),(0,y.useLayoutEffect)(()=>{let t=o.current,n=s.current;if(!t||!n)return;let r=zk(t),i,a=!1,c=e=>x({view:e,size:Ez(t)}),u=gN().scaleExtent(_z).filter(e=>{if(e.type===`wheel`||e.type.startsWith(`touch`))return!0;let{button:t,ctrlKey:n}=e;if(n)return!1;let{mode:r,tool:i}=iD.getState();return t===1||t===0&&(i===`hand`||r===`play`)}).on(`zoom`,({transform:{x:t,y:r,k:o}})=>{clearTimeout(i);for(let e of[n,l.current])e&&(e.style.transform=`translate(${t}px, ${r}px) scale(${o})`,e.style.setProperty(`--zoom`,String(o)));xz.set(e.ref,{x:t,y:r,k:o}),jD(o),a||AD()}).on(`end`,({transform:{x:e,y:t,k:n}})=>{clearTimeout(i),i=setTimeout(()=>c({x:e,y:t,k:n}),yz)});r.call(u).on(`dblclick.zoom`,null).on(`wheel.zoom`,e=>{e.preventDefault();let n=sN(t).k,i=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:1;e.ctrlKey||e.metaKey?u.scaleBy(r,2**(-e.deltaY*i*.01),Vk(e,t)):u.translateBy(r,-e.deltaX*i/n,-e.deltaY*i/n)},{passive:!1});let d=0,p=({x:e,y:t,k:n})=>{a=!0;try{u.transform(r,oN.translate(e,t).scale(n))}finally{a=!1}},m=xz.get(e.ref)??Dz(C.current,Ez(t));p(m),clearTimeout(i),c(m);let h=new ResizeObserver(()=>c(xz.get(e.ref)??m));h.observe(t),f.current=e=>{if(cancelAnimationFrame(d),matchMedia(`(prefers-reduced-motion: reduce)`).matches){p(e);return}let n=sN(t),r=performance.now(),i=t=>{let a=Math.min(1,(t-r)/bz);if(a===1){p(e);return}let o=a<.5?4*a**3:1-(-2*a+2)**3/2;p({x:n.x+(e.x-n.x)*o,y:n.y+(e.y-n.y)*o,k:n.k*(e.k/n.k)**o}),d=requestAnimationFrame(i)};d=requestAnimationFrame(i)};let g=()=>AD();t.addEventListener(`pointerdown`,g,{capture:!0});let _=kD({zoomBy:e=>u.scaleBy(r,e),zoomTo:e=>u.scaleTo(r,e),fit:()=>{AD(),f.current?.(Dz(C.current,Ez(t)))},fitTo:e=>{AD(),f.current?.(Dz(e.map(e=>({box:e})),Ez(t)))},panBy:(e,n)=>{let i=sN(t).k;u.translateBy(r,-e/i,-n/i)},centerOn:e=>f.current?.(Tz(e,sN(t).k,Ez(t)))},e.ref);return()=>{t.removeEventListener(`pointerdown`,g,{capture:!0}),_(),clearTimeout(i),cancelAnimationFrame(d),f.current=null,h.disconnect(),r.on(`.zoom`,null)}},[e.ref]),(0,y.useEffect)(()=>{let t=fD(bD,e.ref,yl,iD),n=zE(yl),r=ZP(bD,yl,MN,e=>Ml(`/api/selection`,e));return()=>{r(),n(),t()}},[e.ref]),(0,y.useEffect)(()=>{let t=o.current,n=s.current,r=c.current;if(t&&n&&r)return AF(r,{viewport:t,layer:n,page:e.ref,frames:()=>C.current})},[e.ref,m]),(0,y.useEffect)(()=>{let e=S.find(e=>e.ref===i),t=o.current;e&&t&&f.current&&(f.current(Dz([e],Ez(t))),a?.())},[i,S,a]);let w=t=>{let n=o.current;if(g||h||_||!n||!u)return;let[r,i]=sN(n).invert(Vk(t,n)),a=++p.current;XP(u,S,{x:r,y:i},IP).then(t=>{t&&a===p.current&&cD(bD,e.ref,t)})},T=(0,y.useMemo)(()=>b?wP(S,b.view,b.size):null,[S,b]);return IN((0,y.useMemo)(()=>b?{frames:S,...b}:null,[S,b])),(0,G.jsxs)(`div`,{ref:o,"data-canvas":!0,className:X(`relative size-full touch-none overflow-hidden bg-background`,h&&!m&&`cursor-grab active:cursor-grabbing`,(g||_)&&!m&&`cursor-crosshair`),children:[(0,G.jsx)(`div`,{ref:e=>{s.current=e,d(e)},"data-layer":!0,className:`absolute top-0 left-0 origin-top-left`,children:e.layoutError?null:(0,G.jsxs)(G.Fragment,{children:[S.map(e=>(0,G.jsx)(nF,{frame:e,live:T?.has(e.ref)??!1,version:t[e.ref]??0,findings:n?.[e.ref],claim:r?.[e.ref],unseen:e.ref in v},e.ref)),(0,G.jsx)(oP,{frames:S}),(0,G.jsx)(WP,{frames:S,container:u}),(0,G.jsx)(pP,{frames:S,container:u}),(0,G.jsx)(bP,{page:e.ref,frames:S})]})}),m?null:(0,G.jsx)(BR,{page:e.ref,frames:()=>C.current,viewport:o,layer:s,trigger:(0,G.jsx)(`div`,{ref:c,"data-hit-layer":!0,className:`absolute inset-0`,onClickCapture:t=>{let n=o.current;if(!(g||_)||!n||!u)return;t.stopPropagation();let[r,i]=sN(n).invert(Vk(t.nativeEvent,n));if(_){nI({x:r,y:i},{page:e.ref,frames:e.frames});return}let a=qP(u,S,{x:r,y:i});a?TP.setState({open:{kind:`new`,pick:a}}):DP()},onClick:e=>{e.metaKey&&w(e.nativeEvent)},onDoubleClick:e=>w(e.nativeEvent)})}),(0,G.jsx)(`div`,{ref:l,"data-notes-layer":!0,className:`pointer-events-none absolute top-0 left-0 origin-top-left`,children:(0,G.jsx)(lz,{page:e.ref,frames:S,container:u})}),(0,G.jsx)(xP,{frames:S}),e.layoutError?(0,G.jsx)(Cz,{error:e.layoutError}):S.length===0?(0,G.jsx)(wz,{}):null]})}function Cz({error:e}){return(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center p-6`,children:(0,G.jsxs)(`div`,{role:`alert`,className:`max-w-md rounded-lg border border-border bg-card p-4 text-body text-card-foreground`,children:[(0,G.jsx)(`p`,{className:`text-panel`,children:`This page's layout does not read`}),(0,G.jsx)(`p`,{className:`mt-1 break-all text-muted-foreground`,children:e.path}),(0,G.jsx)(`p`,{className:`mt-2`,children:e.message})]})})}function wz(){return(0,G.jsxs)(`div`,{role:`status`,className:`pointer-events-none absolute top-1/2 left-1/2 w-105 max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-[55%] text-center text-body leading-[1.6] text-muted-foreground`,children:[(0,G.jsx)(`div`,{"aria-hidden":!0,className:`mx-auto mb-3.5 h-12 w-16 rounded-lg border-[1.5px] border-dashed border-faint`}),(0,G.jsx)(`p`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`This page has no frames`}),(0,G.jsxs)(`p`,{children:[`Pick the Frame tool`,` `,(0,G.jsx)(`kbd`,{className:`rounded-[5px] bg-muted px-1.5 py-0.5 font-mono text-label font-normal text-foreground`,children:`F`}),` `,`and click on the canvas,`,(0,G.jsx)(`br`,{}),`or ask your agent to draw one.`]})]})}function Tz(e,t,n){return e.width*t>n.width-128||e.height*t>n.height-128?Dz([{box:e}],n):{x:n.width/2-(e.x+e.width/2)*t,y:n.height/2-(e.y+e.height/2)*t,k:t}}function Ez(e){return{width:e.clientWidth,height:e.clientHeight}}function Dz(e,t){if(e.length===0||t.width===0||t.height===0)return{x:vz,y:vz,k:1};let n=Math.min(...e.map(({box:e})=>e.x)),r=Math.min(...e.map(({box:e})=>e.y)),i=Math.max(...e.map(({box:e})=>e.x+e.width)),a=Math.max(...e.map(({box:e})=>e.y+e.height)),o=Math.min((t.width-128)/(i-n),(t.height-128)/(a-r),1),s=Math.max(_z[0],o);return{x:(t.width-(i-n)*s)/2-n*s,y:(t.height-(a-r)*s)/2-r*s,k:s}}function Oz(e=AN){let{unseen:t,cursor:n}=e.getState();return(n===null?void 0:t[n])??TN(t)[0]??null}function kz(e,t=F){let[n=``,r=``]=e.split(`/`),i=z(n,r);decodeURIComponent(location.pathname)!==decodeURIComponent(i)&&t(i),yl.setState({focus:e}),uP(e)}function Az(e=AN,t=F){(0,y.useEffect)(()=>{let n=()=>Object.keys(e.getState().unseen).length>0,r=be([{id:`changes.show`,label:`Show change`,group:`changes`,run:()=>{let n=Oz(e);n&&(CN(e,n.frame),kz(n.frame,t))},enabled:n,command:{label:`Show the agent change`,icon:Bn}},{id:`changes.next`,label:`Next change`,group:`changes`,keys:[`BracketRight`],run:()=>{let n=EN(e.getState().unseen,Oz(e)?.frame??null);n&&(CN(e,n.frame),kz(n.frame,t))},enabled:n,command:{label:`Next agent change`,icon:st}}]),i=e.subscribe(xe);return()=>{i(),r()}},[e,t])}function jz(e,t,n){let r=TN(e),i=r.length;if(i<=1){let e=t.author?.agent??null,r=t.frame.split(`/`).at(-1)??t.frame,i=t.whole?1:Math.max(t.elements.length,1),a=`${i} ${i===1?`change`:`changes`}`;return{initial:Nz(e),title:e?`${Mz(e)} updated ${r}`:`${r} changed`,detail:n?`${a}, glowing on the frame`:a,show:!n,next:!1,width:n?300:340}}let a=new Set(r.map(e=>e.author?.agent??null)),[o]=a,s=a.size===1&&o?o:null,c=new Set(r.map(e=>e.frame.split(`/`).slice(0,2).join(`/`))).size,l=r.findIndex(e=>e.id===t.id)+1;return{initial:Nz(s),title:s?`${Mz(s)} changed ${i} frames`:`${i} frames changed`,detail:`on ${c} ${c===1?`page`:`pages`} · ${l} of ${i}`,show:!0,next:!0,width:380}}function Mz(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function Nz(e){return e?e.charAt(0).toUpperCase():null}var Pz=5e3,Fz=R_();function Iz({store:e=AN}){return(0,G.jsxs)(D_,{toastManager:Fz,children:[(0,G.jsx)(Lz,{store:e}),(0,G.jsx)(k_,{className:`absolute right-4 bottom-[84px] z-20 w-auto`,children:(0,G.jsx)(Rz,{})})]})}function Lz({store:e}){return(0,y.useEffect)(()=>{let t=null,n,r=()=>{let r=Oz(e);if(r){clearTimeout(n),n=void 0;let i=jz(e.getState().unseen,r,r.frame in cP.getState().glowing);t===null?t=Fz.add({timeout:0,data:i,onClose:()=>{t=null}}):Fz.update(t,{data:i})}else t!==null&&n===void 0&&(n=setTimeout(()=>{n=void 0,t!==null&&Fz.close(t)},Pz))};r();let i=e.subscribe(r),a=cP.subscribe(r);return()=>{i(),a(),clearTimeout(n),t!==null&&Fz.close(t)}},[e]),null}function Rz(){let{toasts:e}=z_(),[t,n]=Ce([`changes.show`,`changes.next`]);return e.flatMap(e=>{let r=e.data;return r?(0,G.jsx)(A_,{toast:e,"data-change-toast":!0,style:{width:r.width},children:(0,G.jsxs)(j_,{className:`items-center`,children:[r.initial?(0,G.jsx)(`span`,{"aria-hidden":!0,className:`font-bold text-claim`,children:r.initial}):null,(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,G.jsx)(M_,{children:r.title}),(0,G.jsx)(N_,{children:r.detail})]}),r.show?(0,G.jsx)(`button`,{type:`button`,onClick:()=>t?.run(),className:X(zz,`bg-[color-mix(in_srgb,var(--claim)_22%,transparent)] text-claim`),children:`Show`}):null,r.next?(0,G.jsx)(`button`,{type:`button`,"aria-keyshortcuts":`]`,onClick:()=>n?.run(),className:X(zz,`bg-secondary text-foreground`),children:`Next ]`}):null]})},e.id):[]})}var zz=`ml-2 shrink-0 rounded-md px-2 py-[3px] font-medium whitespace-nowrap outline-none hover:brightness-95 focus-visible:ring-2 focus-visible:ring-ring/50`,Bz=y.createContext(void 0);function Vz(e){let t=y.useContext(Bz);if(t===void 0&&!e)throw Error(Ds(72));return t}var Hz={...Eh,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,appliedTriggerProps:(e,t)=>t?e.activeTriggerProps:void 0,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Uz=class extends au{constructor(e,t,n){let r=new _h;super(Wz(e,r,t,n),Gz(r),Hz)}setOpen=(e,t)=>{dh(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,jp(Pp,e))}};function Wz(e,t,n,r=!1){return{...bh(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function Gz(e){return{popupRef:y.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var Kz=Yl(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=ah((e,t)=>new Uz({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),h=!t&&m,g=p.useState(`activeTriggerId`),_=p.useState(`mounted`),v=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),ph(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:b,transitionStatus:x}=mh(h,p),S=p.useState(`isInstantPhase`),C=p.useState(`instantType`),w=p.useState(`lastOpenChangeReason`),T=y.useRef(null);Y(()=>{m&&t&&p.setOpen(!1,jp(qp))},[m,t,p]),Y(()=>{x===`ending`&&w===`none`||x!==`ending`&&S?(C!==`delay`&&(T.current=C),p.set(`instantType`,`delay`)):T.current!==null&&(p.set(`instantType`,T.current),T.current=null)},[x,S,w,C,p]),Y(()=>{h&&(g??p.set(`payload`,void 0))},[p,g,h]),y.useImperativeHandle(o,()=>({unmount:b,close:()=>p.setOpen(!1,jp(Xp))}),[b,p]);let E=h||_||!t&&a!==`none`;return(0,G.jsxs)(Bz.Provider,{value:p,children:[l&&(0,G.jsx)(oh,{handle:l,store:p}),E&&(0,G.jsx)(qz,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function qz({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=$m(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=Xm(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=y.useMemo(()=>ps(a.reference,i.reference),[a.reference,i.reference]);return hh(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??qs}),null}var Jz=y.createContext(void 0);function Yz(){return y.useContext(Jz)}var Xz=`data-base-ui-tooltip-trigger`;function Zz(e){let t=Fu(e);return q(t)?t:null}var Qz=Xl(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d,...f}=e,p=Vz(!0),m=Dh(a)??p;if(!m)throw Error(Ds(82));let h=OI(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),b=y.useRef(null),x=u??0,{registerTrigger:S,isMountedByThisTrigger:C}=fh(h,b,m,{payload:o,closeOnClick:l,closeDelay:x}),w=Yz(),{activeIdRef:T,delayRef:E,isInstantPhase:D,hasProvider:O}=hm(v,{open:_}),k=Ph(v);m.useSyncedValue(`isInstantPhase`,D);let A=m.useState(`disabled`),j=s??A,M=am(j),N=m.useState(`trackCursorAxis`),P=m.useState(`disableHoverablePopup`),F=y.useRef(!1),I=hu(),L=y.useRef(void 0);function R(){return O&&T.current!=null?0:c??w??600}function z(e){let t=b.current;if(!t||!e)return!1;let n=Pu(e,`[${Xz}]`);return n!==null&&n!==t&&Q(t,n)}function B(e){let t=z(e);return F.current=t,t&&(k.openChangeTimeout.clear(),k.restTimeout.clear(),k.restTimeoutPending=!1,I.clear()),t}let ee=Lh(v,{enabled:!j,mouseOnly:!0,move:!1,handleClose:!P&&N!==`both`?$h():null,restMs:R,delay(){return u==null&&O?{close:cm(E.current,`close`)}:{close:x}},triggerElementRef:b,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!F.current}}),te=kh(v,{enabled:!j}).reference,ne=e=>{let t=F.current,n=Zz(e),r=B(n),i=b.current,a=i&&n&&Q(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`)m.setOpen(!1,jp(Fp,e));else if(t&&!r&&a&&!M.current&&!m.select(`open`)&&i&&Sd(L.current)){let t=()=>{!F.current&&!M.current&&!m.select(`open`)&&m.setOpen(!0,jp(Fp,e,i))},n=R();n===0?(I.clear(),t()):I.start(n,t)}},re=m.useState(`appliedTriggerProps`,C||N!==`none`);return Zs(`button`,e,{state:{open:_},ref:[t,S,b],props:[ee,te,re,{onMouseOver(e){ne(e.nativeEvent)},onFocus(e){z(Zz(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){F.current=!1,I.clear(),L.current=void 0},onPointerEnter(e){L.current=e.pointerType},onPointerDown(e){L.current=e.pointerType,m.set(`closeOnClick`,l),l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},id:h,[sd]:j?``:void 0,[Xz]:j?void 0:``},f],stateAttributesMapping:rd})}),$z=y.createContext(void 0);function eB(){let e=y.useContext($z);if(e===void 0)throw Error(Ds(70));return e}var tB=y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Vz().useState(`mounted`)||n?(0,G.jsx)($z.Provider,{value:n,children:(0,G.jsx)(rm,{ref:t,...r})}):null}),nB=y.createContext(void 0);function rB(){let e=y.useContext(nB);if(e===void 0)throw Error(Ds(71));return e}var iB=y.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=np,style:g,..._}=e,v=Vz(),b=eB(),x=v.useState(`open`),S=v.useState(`mounted`),C=v.useState(`trackCursorAxis`),w=v.useState(`disableHoverablePopup`),T=v.useState(`floatingRootContext`),E=v.useState(`instantType`),D=v.useState(`transitionStatus`),O=y_({anchor:i,positionMethod:a,floatingRootContext:T,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,adaptiveOrigin:v.useState(`adaptiveOrigin`)}),k=C_(e,y.useMemo(()=>({open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:C===`none`?E:`tracking-cursor`}),[x,O.side,O.align,O.anchorHidden,C,E]),{styles:O.positionerStyles,transitionStatus:D,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!S,inert:!x||C===`both`||w});return(0,G.jsx)(nB.Provider,{value:O,children:k})}),aB=y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Vz(),{side:s,align:c}=rB(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);Yf({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Fh(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return Zs(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[rh,f,S_(d),a],stateAttributesMapping:od})}),oB=y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Vz(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=rB();return Zs(`div`,e,{state:{open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)},ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:ad})}),sB=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=y.useMemo(()=>({open:t,close:n}),[t,n]);return(0,G.jsx)(Jz.Provider,{value:t,children:(0,G.jsx)(mm,{delay:i,timeoutMs:r,children:e.children})})};function cB({delay:e=0,...t}){return(0,G.jsx)(sB,{"data-slot":`tooltip-provider`,delay:e,...t})}function lB({...e}){return(0,G.jsx)(Kz,{"data-slot":`tooltip`,...e})}function uB({...e}){return(0,G.jsx)(Qz,{"data-slot":`tooltip-trigger`,...e})}function dB({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,children:a,...o}){return(0,G.jsx)(tB,{children:(0,G.jsx)(iB,{align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,G.jsxs)(aB,{"data-slot":`tooltip-content`,className:X(`z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...o,children:[a,(0,G.jsx)(oB,{className:`z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`})]})})})}function fB({label:e,keys:t,children:n,side:r=`top`}){let i=t?.[0];return(0,G.jsxs)(lB,{children:[(0,G.jsx)(uB,{render:n}),(0,G.jsx)(dB,{side:r,sideOffset:6,className:`rounded-md px-2 py-[5px] text-[11px]`,children:i?`${e} ${LF(i)}`:e})]})}function pB({...e}){return(0,G.jsx)(rR,{"data-slot":`dropdown-menu`,...e})}function mB({...e}){return(0,G.jsx)(mR,{"data-slot":`dropdown-menu-trigger`,...e})}function hB({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){return(0,G.jsx)(lL,{children:(0,G.jsx)(ML,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,G.jsx)(oL,{"data-slot":`dropdown-menu-content`,className:X(`z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95`,i),...a})})})}function gB({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(RI,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:X(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function _B({...e}){return(0,G.jsx)(aR,{"data-slot":`dropdown-menu-sub`,...e})}function vB({className:e,inset:t,children:n,...r}){return(0,G.jsxs)(xR,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:X(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,G.jsx)(pt,{className:`ml-auto`})]})}function yB({align:e=`start`,alignOffset:t=-3,side:n=`right`,sideOffset:r=0,className:i,...a}){return(0,G.jsx)(hB,{"data-slot":`dropdown-menu-sub-content`,className:X(`w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,i),align:e,alignOffset:t,side:n,sideOffset:r,...a})}function bB({...e}){return(0,G.jsx)(IL,{"data-slot":`dropdown-menu-radio-group`,...e})}function xB({className:e,children:t,inset:n,...r}){return(0,G.jsxs)(BL,{"data-slot":`dropdown-menu-radio-item`,"data-inset":n,className:X(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[(0,G.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-radio-item-indicator`,children:(0,G.jsx)(VL,{children:(0,G.jsx)(lt,{})})}),t]})}function SB({className:e,...t}){return(0,G.jsx)(_R,{"data-slot":`dropdown-menu-separator`,className:X(`-mx-1 my-1 h-px bg-border`,e),...t})}var CB={name:`frameboard`,version:`0.7.0`,description:`A local design board that coding agents draw on as plain HTML files`,keywords:[`design`,`board`,`canvas`,`html`,`coding-agent`,`claude-code`,`cli`],homepage:`https://github.com/erclx/frameboard#readme`,bugs:{url:`https://github.com/erclx/frameboard/issues`},repository:{type:`git`,url:`git+https://github.com/erclx/frameboard.git`},license:`MIT`,type:`module`,bin:{frameboard:`dist/cli.js`},files:[`dist`],engines:{node:`>=22`},scripts:{typecheck:`tsc --noEmit`,build:`vite build && rolldown -c rolldown.config.ts && bun scripts/copy-faces.ts`,dev:`WORKTREE_PORT_OFFSET=$(bash scripts/worktree-port.sh) && export WORKTREE_PORT_OFFSET && vite`,preview:'node dist/cli.js serve --root "${CANON_PREVIEW_ROOT:-.}/test/fixtures/boards/basic" --no-open --port ${PREVIEW_PORT:-4173}',test:`vitest`,"test:run":`vitest run --reporter=verbose`,"test:ui":`vitest --ui`,"test:coverage":`vitest run --coverage --project node`,"test:e2e":`WORKTREE_PORT_OFFSET=$(bash scripts/worktree-port.sh) && export WORKTREE_PORT_OFFSET && playwright test`,"test:e2e:changed":`WORKTREE_PORT_OFFSET=$(bash scripts/worktree-port.sh) && export WORKTREE_PORT_OFFSET && playwright test --only-changed`,"test:e2e:ui":`WORKTREE_PORT_OFFSET=$(bash scripts/worktree-port.sh) && export WORKTREE_PORT_OFFSET && playwright test --ui`,"test:e2e:report":`playwright show-report`,"check:full":`bun scripts/verify.ts && bun run test:e2e`,"measure:canvas":`bun run build && playwright test -c e2e/perf/playwright.config.ts`,"smoke:prod":`bun e2e/screenshot.ts --check-console-clean --require-base-url`,prepare:`husky`,"design:sync":`bun scripts/design-sync.ts`,check:`bun scripts/verify.ts`,"check:format":`oxfmt --check .`,format:`oxfmt .`,lint:`oxlint --max-warnings 0`,"lint:fix":`oxlint --fix --max-warnings 0`,screenshot:`PREVIEW_PORT=$(bash scripts/worktree-port.sh 4173) && export PREVIEW_PORT && bash scripts/screenshot.sh`,"screenshot:compare":`bun run build && bun e2e/compare.ts`,"readme-screenshot":`PREVIEW_PORT=$(bash scripts/worktree-port.sh 4173) && export PREVIEW_PORT && bash scripts/readme-screenshot.sh`},devDependencies:{"@atlaskit/pragmatic-drag-and-drop":`4.0.0`,"@atlaskit/pragmatic-drag-and-drop-hitbox":`3.0.0`,"@base-ui/react":`^1.9.0`,"@bramus/specificity":`^2.4.3`,"@commitlint/cli":`^21.2.3`,"@commitlint/config-conventional":`^21.2.3`,"@fontsource-variable/caveat":`^5.3.0`,"@fontsource-variable/geist":`^5.3.0`,"@fontsource-variable/geist-mono":`^5.3.0`,"@hono/node-server":`^2.1.5`,"@playwright/test":`^1.64.1`,"@tailwindcss/vite":`^4.3.3`,"@testing-library/jest-dom":`^7.0.1`,"@testing-library/react":`^16.3.3`,"@testing-library/user-event":`^14.6.8`,"@types/d3-drag":`^3.0.7`,"@types/d3-selection":`^3.0.12`,"@types/d3-zoom":`^3.0.9`,"@types/jsdom":`^30.0.0`,"@types/node":`^26.6.5`,"@types/react":`^19.3.0`,"@types/react-dom":`^19.3.0`,"@types/ws":`^8.18.2`,"@vitejs/plugin-react":`^6.1.2`,"@vitest/browser-playwright":`^5.0.4`,"@vitest/coverage-v8":`^5`,"@vitest/ui":`^5`,chokidar:`^5.0.0`,"class-variance-authority":`^0.7.1`,cmdk:`^1.1.1`,cn:`^0.4.0`,commander:`^15.0.0`,"css-select":`^7.0.0`,"d3-drag":`3.0.0`,"d3-selection":`^3.0.0`,"d3-zoom":`^3.0.0`,"eslint-plugin-check-file":`^3.3.2`,"eslint-plugin-simple-import-sort":`^14.0.0`,"fast-check":`^4.10.2`,hono:`^4.13.13`,husky:`^9.1.7`,jsdom:`^30.1.2`,"lucide-react":`^1.57.0`,oxfmt:`0.73.0`,oxlint:`1.88.0`,parse5:`^8.0.1`,"parse5-htmlparser2-tree-adapter":`^8.0.1`,playwright:`^1.64.1`,postcss:`^8.5.6`,react:`^19.3.1`,"react-dom":`^19.3.1`,"react-resizable-panels":`^4.14.5`,rolldown:`^1.2.14`,shadcn:`^4.21.5`,tailwindcss:`^4.3.3`,tinykeys:`^4.0.1`,"tw-animate-css":`^1.4.0`,typescript:`^7`,vite:`^8.3.4`,vitest:`^5`,wouter:`^3.13.0`,ws:`^8.22.0`,zod:`^4.6.7`,zustand:`^5.0.15`},dependencies:{"playwright-core":`1.64.1`}};function wB({className:e,...t}){return(0,G.jsx)(hB,{className:X(`w-60 rounded-[10px] p-1 text-xs shadow-[0_12px_40px_rgba(0,0,0,.3)] ring-border`,e),...t})}function TB({action:e,label:t,keys:n,children:r}){let i=(e?.keys??n)?.[0];return(0,G.jsxs)(gB,{disabled:!e||!Se(e),onClick:()=>e?.run(),className:EB,children:[r??e?.label??t,i?(0,G.jsx)(DB,{children:LF(i)}):null]})}var EB=`h-7 rounded-md px-2 py-0 text-xs`;function DB({children:e}){return(0,G.jsx)(`kbd`,{className:`ml-auto grid h-5 min-w-5 place-items-center rounded-[5px] bg-muted px-[5px] font-sans text-label font-normal text-muted-foreground`,children:e})}function OB({name:e,align:t=`start`}){let[n]=Ce([`help.shortcuts`]),r=Ee(`theme`),i=r.find(e=>e.checked?.());return(0,G.jsxs)(pB,{children:[(0,G.jsx)(mB,{"aria-label":e?`${e}, from git user.name`:`Account`,className:`rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,children:(0,G.jsx)(kB,{name:e})}),(0,G.jsxs)(wB,{align:t,alignOffset:t===`start`?-25:-10,sideOffset:7,children:[e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 p-2`,children:[(0,G.jsx)(kB,{name:e}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate font-semibold`,title:e,children:e}),(0,G.jsx)(`p`,{className:`text-label font-normal text-muted-foreground`,children:`From git user.name`})]})]}),(0,G.jsx)(SB,{})]}):null,(0,G.jsx)(TB,{action:n,label:`Keyboard shortcuts`}),(0,G.jsxs)(_B,{children:[(0,G.jsxs)(vB,{disabled:r.length===0,className:`${EB} data-disabled:opacity-50`,children:[`Theme`,i?(0,G.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:i.label}):null]}),(0,G.jsx)(yB,{className:`rounded-[10px] ring-border`,children:(0,G.jsx)(bB,{value:i?.id??``,children:r.map(e=>(0,G.jsx)(xB,{value:e.id,onClick:()=>e.run(),className:`h-7 py-0 text-xs`,children:e.label},e.id))})})]}),(0,G.jsx)(gB,{className:EB,render:(0,G.jsx)(`a`,{href:CB.homepage}),children:`Docs`})]})]})}function kB({name:e}){return(0,G.jsx)(`span`,{"aria-hidden":!0,"data-avatar":!0,className:`grid size-[22px] shrink-0 place-items-center rounded-full bg-foreground text-[10px] font-bold text-card`,children:e?ez(e):(0,G.jsx)(vr,{className:`size-3`})})}var AB=[{id:`view.zoomIn`,label:`Zoom in`},{id:`view.zoomOut`,label:`Zoom out`},{id:`view.zoomToFit`,label:`Zoom to fit`}],jB=[{id:`view.zoom50`,label:`50%`},{id:`view.zoom100`,label:`100%`},{id:`view.zoom200`,label:`200%`}],MB=[...AB,...jB].map(e=>e.id);function NB({align:e=`end`,className:t}){let n=(0,y.useRef)(null),r=Ce(MB);return(0,y.useEffect)(()=>{let e=()=>{n.current&&(n.current.textContent=PB(OD.zoom()))};return e(),OD.onZoom(e)},[]),(0,G.jsxs)(pB,{children:[(0,G.jsxs)(mB,{"aria-label":`Zoom`,className:X(`flex h-6 items-center gap-1 rounded-md px-1 text-muted-foreground tabular-nums outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 aria-expanded:text-foreground`,t),children:[(0,G.jsx)(`span`,{ref:n,"data-zoom-level":!0}),(0,G.jsx)(dt,{"aria-hidden":!0,className:`size-2.5`})]}),(0,G.jsxs)(wB,{align:e,sideOffset:8,className:`w-48`,children:[AB.map((e,t)=>(0,G.jsx)(TB,{action:r[t],label:e.label},e.id)),(0,G.jsx)(SB,{}),jB.map((e,t)=>(0,G.jsx)(TB,{action:r[AB.length+t],label:e.label,children:e.label},e.id))]})]})}function PB(e){return`${Math.round(e*100)}%`}function FB({project:e}){let[t]=Ce([`view.hideUi`]),n=iz()??null;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`absolute top-3 left-3 z-10 flex max-w-[calc(100%-10rem)] items-center gap-1.5 rounded-lg border border-border bg-card py-1 pr-1.5 pl-2.5 text-panel`,children:[(0,G.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,G.jsx)(fB,{label:`Show UI`,keys:t?.keys,side:`bottom`,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":`Show UI`,onClick:()=>t?.run(),className:`grid size-6 shrink-0 place-items-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:(0,G.jsx)(En,{"aria-hidden":!0,className:`size-[15px]`})})})]}),(0,G.jsxs)(`div`,{className:`absolute top-3 right-3 z-10 flex h-[34px] items-center gap-1.5 rounded-lg border border-border bg-card pr-2.5 pl-1.5`,children:[(0,G.jsx)(OB,{name:n,align:`end`}),(0,G.jsx)(NB,{className:`text-foreground`})]})]})}function IB(){return(0,G.jsx)(`p`,{role:`status`,className:`pointer-events-none absolute top-3.5 left-1/2 z-10 -translate-x-1/2 rounded-full bg-primary px-3 py-1.5 font-medium whitespace-nowrap text-primary-foreground`,children:`Playing. Clicks go to the frames. Esc to edit`})}var LB=[[{id:`tool.move`,label:`Move`,keys:[`v`],icon:bn},{id:`tool.hand`,label:`Hand`,keys:[`h`],icon:Gt},{id:`tool.frame`,label:`Frame`,keys:[`f`],icon:Ut},{id:`tool.note`,label:`Note`,keys:[`n`],icon:mn}],[{id:`edit.undo`,label:`Undo`,icon:gr},{id:`edit.redo`,label:`Redo`,icon:Rn}],[{id:`view.zoomToFit`,label:`Zoom to fit`,keys:[`Shift+Digit1`],icon:fn},{id:`theme.toggle`,label:`Theme`,icon:er,darkIcon:vn}]],RB=[{id:`mode.edit`,label:`Edit`,icon:An},{id:`mode.play`,label:`Play`,icon:Mn}],zB=[...LB.flat(),...RB].map(e=>e.id);function BB(){let e=new Map(Ce(zB).map((e,t)=>[zB[t],e]));return(0,G.jsxs)(`div`,{role:`toolbar`,"aria-label":`Tools`,className:`absolute bottom-4 left-1/2 z-10 flex max-w-[calc(100%-1.5rem)] -translate-x-1/2 items-center gap-0.5 overflow-x-auto rounded-xl border border-border bg-card p-[5px] shadow-[0_6px_24px_rgba(0,0,0,.18),0_1px_3px_rgba(0,0,0,.12)]`,children:[LB.map((t,n)=>(0,G.jsxs)(y.Fragment,{children:[n>0?(0,G.jsx)(UB,{}):null,t.map(t=>(0,G.jsx)(VB,{slot:t,action:e.get(t.id)},t.id))]},t[0]?.id)),(0,G.jsx)(UB,{}),(0,G.jsx)(`div`,{className:`flex shrink-0 rounded-lg bg-muted p-0.5`,children:RB.map(t=>(0,G.jsx)(HB,{slot:t,action:e.get(t.id)},t.id))})]})}function VB({slot:e,action:t}){let{label:n,keys:r,on:i,enabled:a,run:o}=WB(e,t),s=e.icon,c=e.darkIcon;return(0,G.jsx)(fB,{label:n,keys:r,children:(0,G.jsxs)(`button`,{type:`button`,"aria-label":n,"aria-pressed":t?.checked?i:void 0,"aria-disabled":!a||void 0,onClick:o,className:X(`grid size-8 shrink-0 place-items-center rounded-[7px] text-foreground outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:bg-transparent`,i&&`bg-primary text-primary-foreground hover:bg-primary aria-disabled:hover:bg-primary`),children:[(0,G.jsx)(s,{"aria-hidden":!0,className:X(`size-4`,c&&`dark:hidden`)}),c?(0,G.jsx)(c,{"aria-hidden":!0,className:`hidden size-4 dark:block`}):null]})})}function HB({slot:e,action:t}){let{label:n,keys:r,on:i,enabled:a,run:o}=WB(e,t),s=e.icon;return(0,G.jsx)(fB,{label:n,keys:r,children:(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":i,"aria-disabled":!a||void 0,onClick:o,className:X(`flex h-[26px] items-center gap-[5px] rounded-md px-[9px] font-medium text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50`,i&&e.id===`mode.play`?`bg-primary text-primary-foreground hover:text-primary-foreground`:i&&`bg-card text-foreground ring-1 ring-border`),children:[(0,G.jsx)(s,{"aria-hidden":!0,className:`size-3.5`}),n]})})}function UB(){return(0,G.jsx)(`span`,{"aria-hidden":!0,className:`mx-[5px] h-5 w-px shrink-0 bg-border`})}function WB(e,t){let n=t?Se(t):!1;return{label:t?.label??e.label,keys:t?.keys??e.keys,on:t?.checked?.()??!1,enabled:n,run:()=>{t&&n&&t.run()}}}function GB(){return ue()(()=>({open:!1,focusRequest:0}))}var KB=GB();function qB(e){return fe(KB,e)}function JB(e=KB,t=iD){t.setState({hideUi:!1}),e.setState(e=>({open:!0,focusRequest:e.focusRequest+1}))}function YB(e=KB){e.setState({open:!1})}function XB(e=KB,t=iD){(0,y.useEffect)(()=>{let n=be([{id:`find.open`,label:`Find`,group:`tool`,keys:[`$mod+KeyF`],run:()=>JB(e,t),command:{label:`Find frames, elements, and text`,icon:Kn}}]);return()=>{n(),YB(e)}},[e,t])}var ZB=ue()(()=>({session:null})),QB=null;function $B(e,{live:t=yl,unseen:n=AN,go:r=F}={}){eV();let i=OD.page(),a=null,o=()=>{if(a===null)return;let[e=``,n=``]=a.split(`/`),o=tV(a);if(OD.page()!==o){i!==o&&(i=o,r(z(e,n)));return}let s=nV(t.getState().board,a);s&&(a=null,OD.centerOn(s))},s=e=>{e!==null&&(a=e,o())},c=n.subscribe((t,n)=>{let r=TN(t.unseen).filter(t=>t.author?.session===e&&n.unseen[t.frame]?.id!==t.id);s(r.at(-1)?.frame??null)}),l=t.subscribe((t,n)=>{if(!t.listeners.some(t=>t.session===e)){eV();return}let r=Object.values(t.claims).filter(t=>t.session===e&&n.claims[t.frame]?.session!==e);r.length>0?s(r.at(-1)?.frame??null):t.board!==n.board&&o()}),u=OD.onHandMove(eV),d=OD.onAttach(()=>{let e=OD.page();if(e===null)return;let n=t.getState().focus;n!==null&&e===tV(n)&&(i=e),e===i?o():eV()}),f=be([{id:`follow.stop`,label:`Stop following`,group:`changes`,run:eV,command:{label:`Stop following the agent`,icon:on}}]);QB=()=>{f(),d(),u(),l(),c()},ZB.setState({session:e})}function eV(){if(!QB)return;let e=QB;QB=null,e(),ZB.setState({session:null})}function tV(e){let[t=``,n=``]=e.split(`/`);return`${t}/${n}`}function nV(e,t){for(let n of e?.projects??[])for(let e of n.pages){let n=e.frames.find(e=>e.ref===t);if(n)return n.box}return null}function rV({listeners:e,claims:t}){let n=fe(ZB,e=>e.session);if(e.length===0)return null;let r=new Map(Object.values(t).map(e=>[e.session,e.agent]));return(0,G.jsx)(`span`,{className:`ml-1 flex items-center`,children:e.map((e,t)=>{let i=r.has(e.session),a=n===e.session,o=(0,G.jsx)(`span`,{"aria-hidden":!0,className:X(`grid size-[22px] place-items-center rounded-full text-[9px] font-bold text-card shadow-[0_0_0_2px_var(--sidebar)]`,i?`bg-claim`:`bg-[color-mix(in_srgb,var(--claim)_55%,var(--sidebar))]`),children:mP(r.get(e.session)??gP(e.tag))});return(0,G.jsxs)(`button`,{type:`button`,"aria-label":`${e.tag}, ${i?`editing`:`listening`}`,"aria-pressed":a,title:a?`Stop following ${e.tag}`:`Follow ${e.tag}`,"data-editing":i||void 0,onClick:()=>a?eV():$B(e.session),className:X(`rounded-full outline-none hover:brightness-110 focus-visible:ring-2 focus-visible:ring-ring/50`,a?`flex items-center gap-1.5 py-0.5 pr-2 pl-0.5 text-[11px] font-semibold text-claim shadow-[0_0_0_1.5px_var(--claim)]`:t>0&&`-ml-1.5`,a&&t>0&&`ml-1.5`),children:[o,a?`Following`:null]},e.session)})})}function iV(e,t=aV){let n=Z(e=>e.board),[r,i]=(0,y.useState)();return(0,y.useEffect)(()=>{let n=!0;return t(e).catch(()=>null).then(e=>{n&&i(e)}),()=>{n=!1}},[e,n,t]),r}async function aV(e){let t=await(await fetch(`/api/projects/${encodeURIComponent(e)}/tokens`)).json();return t.ok?t.data:null}var oV=[[{id:`arrange.alignLeft`,icon:rt},{id:`arrange.alignCenter`,icon:qe},{id:`arrange.alignRight`,icon:Ze}],[{id:`arrange.alignTop`,icon:tt},{id:`arrange.alignMiddle`,icon:Ge},{id:`arrange.alignBottom`,icon:Ye}],[{id:`arrange.distributeHorizontal`,icon:$e},{id:`arrange.distributeVertical`,icon:at}]],sV=oV.flat().map(({id:e})=>e);function cV(){let e=Ce(sV),t=new Map(e.flatMap(e=>e?[[e.id,e]]:[]));return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-arrange`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-arrange`,className:`mb-2 text-xs font-semibold`,children:`Arrange`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:oV.map(e=>(0,G.jsx)(`div`,{role:`group`,className:`flex gap-0.5 rounded-md bg-input p-0.5`,children:e.map(({id:e,icon:n})=>(0,G.jsx)(lV,{action:t.get(e),icon:n},e))},e[0]?.id))})]})}function lV({action:e,icon:t}){return e?(0,G.jsx)(fB,{label:e.label,keys:e.keys,side:`bottom`,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":e.label,disabled:!Se(e),onClick:e.run,className:`grid h-[22px] w-7 place-items-center rounded-[5px] text-muted-foreground outline-none hover:bg-sidebar hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 active:bg-sidebar disabled:pointer-events-none disabled:opacity-40`,children:(0,G.jsx)(t,{"aria-hidden":!0,className:`size-[13px]`,strokeWidth:1.6})})}):null}var uV=`data-valid`,dV=`data-invalid`,fV={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},pV={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},mV={valid(e){return e===null?null:e?{[uV]:``}:{[dV]:``}}},hV={invalid:void 0,name:void 0,validityData:{state:fV,errors:[],error:``,value:``,initialValue:null},setValidityData:Gs,disabled:void 0,setTouched:Gs,setDirty:Gs,setFilled:Gs,setFocused:Gs,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:pV,registerFieldControl:Gs,validation:{getValidationProps:(e,t=qs)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:Gs,getInputControl:()=>null,commit:async()=>{},change:Gs}},gV=y.createContext(hV);function _V(e=!0){let t=y.useContext(gV);if(t.setValidityData===Gs&&!e)throw Error(Ds(28));return t}var vV=y.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Gs,validationMode:`onSubmit`,submitCountRef:{current:0}});function yV(){return y.useContext(vV)}var bV=y.createContext({controlId:void 0,registerControlId:Gs,resetControlId:Gs,labelId:void 0,setLabelId:Gs,messageIds:[],setMessageIds:Gs,getDescriptionProps:e=>e});function xV(){return y.useContext(bV)}function SV(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=xV(),o=OI(),s=os(()=>Symbol()),c=y.useRef(!1),l=y.useRef(!1),u=J(()=>{c.current&&i!==Gs&&(c.current=!1,i(s.current,void 0))});return Y(()=>{if(!n||i===Gs){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}e===void 0?u():(c.current=!0,i(s.current,e))},[t,n,i,a,o,s,u]),Y(()=>u,[u]),(n?r:void 0)??t??o}function CV(e,t,n){let{setFocused:r,focusOwnerRef:i}=_V(),a=J(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return Y(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}function wV(e,t,n,r,i=!0,a){let{registerFieldControl:o}=_V(),s=os(()=>Symbol());Y(()=>{let c=s.current;i?o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}):o(c,void 0)},[e,i,r,t,a,o,s,n]),Y(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var TV=y.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFilled:b,validationMode:x,validation:S}=_V(),{clearErrors:C,elementRef:w,submitCountRef:T}=yV(),E=h||s,D=m??a,O={...p,disabled:E},{labelId:k}=xV(),A=SV({id:i}),j=o!==void 0,M=o==null?void 0:String(o),N=J(()=>S.inputRef.current?.value);wV(S.inputRef,A,M,N,!E,a),Y(()=>{let e=M??S.inputRef.current?.value;e!==void 0&&b(e!==``)},[M,l,S.inputRef,b]),GL(M,()=>{M!==void 0&&(C(D),_(M!==(v.initialValue??``)),S.change(M))});let P=y.useRef(null),F=CV(E,P),I=hu();return Zs(`input`,e,{ref:[t,P],state:O,props:[{id:A,disabled:E,name:D,ref:S.inputRef,"aria-labelledby":k,autoFocus:u,...j?{value:o}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=jp(Np,e.nativeEvent);c?.(t,n),!j&&(_(t!==(v.initialValue??``)),b(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(C(D),S.change(t)))},onFocus(){F(!0)},onBlur(e){if(g(!0),F(!1),x===`onBlur`){let t=e.currentTarget.value;S.commit(t),j&&queueMicrotask(()=>{let e=S.inputRef.current?.value;e!==void 0&&e!==t&&e!==(v.initialValue??``)&&S.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){g(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===w.current&&!e.defaultPrevented){let t=e.currentTarget,n=T.current;I.start(0,()=>{T.current===n&&S.commit(t.value)})}else S.commit(t)}}},f,e=>S.getValidationProps(E,e)],stateAttributesMapping:mV})}),EV=y.forwardRef(function(e,t){return(0,G.jsx)(TV,{ref:t,...e})});function DV({className:e,type:t,...n}){return(0,G.jsx)(EV,{type:t,"data-slot":`input`,className:X(`h-[26px] w-full min-w-0 rounded-md border-0 bg-input px-2 text-xs text-foreground tabular-nums outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-2 aria-invalid:ring-destructive/40`,e),...n})}function OV(e){let{nativeEvent:t,currentTarget:n}=e;return t instanceof InputEvent&&(t.inputType===`historyUndo`||t.inputType===`historyRedo`)&&n.ownerDocument.activeElement!==n}function kV({label:e,prefix:t,shown:n,disabled:r,onCommit:i,className:a,inset:o=`pl-[26px]`,inputClassName:s}){let[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(null);u&&u.over!==n&&d(null);let f=u?.over===n?u.value:null,p=(0,y.useRef)(!1),m=()=>{if(p.current){p.current=!1;return}if(c===null)return;l(null);let e=c.trim();e!==n&&(d({value:e,over:n}),i(e).then(e=>{e||d(null)}))};return(0,G.jsxs)(`label`,{className:X(`relative block`,a),children:[t?(0,G.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2 flex -translate-y-1/2 items-center text-xs text-faint`,children:t}):null,(0,G.jsx)(DV,{"aria-label":e,className:X(t?o:void 0,s),value:c??f??n,disabled:r,onFocus:e=>e.currentTarget.select(),onChange:e=>{OV(e)||l(e.currentTarget.value)},onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&(l(null),p.current=!0,e.currentTarget.blur())}})]})}var AV=/^#[0-9a-f]{6}$/i,jV=`flex h-[26px] items-center gap-2 rounded-md bg-input px-2 text-xs`,MV=`-ml-1 max-w-max truncate rounded-[4px] bg-[color-mix(in_srgb,var(--foreground)_9%,transparent)] px-1.5 py-px`;function NV(e,t){let n=`token`in e?`var(${e.token})`:e.raw;if(t>=100)return n;if(`raw`in e&&AV.test(e.raw)){let n=Math.round(t/100*255).toString(16).padStart(2,`0`);return`${e.raw}${n}`}return`color-mix(in srgb, ${n} ${t}%, transparent)`}function PV(e,t,n){return e.find(e=>e.name===t)?.[n]??null}function FV(e,t,n){let r=e.token?PV(t,e.token,n):e.value;return r===null?null:e.percent>=100?r:`color-mix(in srgb, ${r} ${e.percent}%, transparent)`}function IV(e){return e.replace(/^--/,``)}function LV(e){let t=Number(e.replace(/%$/,``).trim());return e.trim()===``||!Number.isFinite(t)?null:Math.min(100,Math.max(0,Math.round(t)))}function RV(e,t){let n=t!==``&&e.endsWith(t)?e.slice(0,-t.length):e,r=Number(n.trim());return n.trim()===``||!Number.isFinite(r)?null:Math.max(0,Math.round(r))}function zV({color:e,className:t}){return(0,G.jsx)(`span`,{"aria-hidden":!0,className:X(`size-3.5 shrink-0 rounded-[3px] shadow-[inset_0_0_0_1px_rgba(127,127,127,.3)]`,e===null&&`border border-dashed border-faint`,t),style:e===null?void 0:{background:e}})}function BV(){return(0,G.jsx)(`span`,{role:`img`,"aria-label":`Raw value, not a token`,title:`Raw value`,children:(0,G.jsx)(ht,{"aria-hidden":!0,className:`size-[13px] text-note`})})}function VV({label:e,value:t,tokens:n,theme:r,disabled:i,onWrite:a}){let o=t.token?{token:t.token}:{raw:t.value},s=t.token?PV(n,t.token,r):null,c=FV(t,n,r),l=t.token!==null||AV.test(t.value);return(0,G.jsxs)(`div`,{className:jV,children:[(0,G.jsx)(HV,{label:`${e} color`,color:c!==null&&AV.test(c)?c:null,disabled:i,onPick:e=>a(NV({raw:e},t.percent)),children:(0,G.jsx)(zV,{color:c})}),(0,G.jsxs)(pB,{children:[(0,G.jsx)(mB,{"aria-label":`${e} token`,disabled:i||n.length===0,className:X(`min-w-0 truncate text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-default`,t.token?MV:`flex-1 tabular-nums`),children:t.token?IV(t.token):t.value.replace(/^#/,``)}),(0,G.jsx)(wB,{align:`start`,sideOffset:6,className:`w-52`,children:n.map(e=>(0,G.jsxs)(gB,{className:EB,onClick:()=>void a(NV({token:e.name},t.percent)),children:[(0,G.jsx)(zV,{color:e[r]}),IV(e.name)]},e.name))})]}),(0,G.jsx)(kV,{label:`${e} opacity`,className:`ml-auto w-12 shrink-0`,inputClassName:`h-6 px-0 text-right text-muted-foreground focus-visible:text-foreground`,shown:`${t.percent}%`,disabled:i||!l,onCommit:async e=>{let t=LV(e);return t!==null&&a(NV(o,t))}}),t.token?(0,G.jsx)(`button`,{type:`button`,"aria-label":`Detach ${IV(t.token)}`,title:`Detach the token to its value`,disabled:i||s===null,onClick:()=>{s!==null&&a(NV({raw:s},t.percent))},className:`grid shrink-0 place-items-center rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 disabled:opacity-50`,children:(0,G.jsx)($t,{"aria-hidden":!0,className:`size-[13px]`})}):(0,G.jsx)(BV,{})]})}function HV({label:e,color:t,disabled:n,onPick:r,children:i}){let a=(0,y.useRef)(null),o=(0,y.useRef)(r);return(0,y.useEffect)(()=>{o.current=r}),(0,y.useEffect)(()=>{a.current&&(a.current.value=t??`#000000`)},[t]),(0,y.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>void o.current(e.value);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,G.jsxs)(`label`,{className:`relative grid shrink-0 place-items-center`,children:[i,(0,G.jsx)(`input`,{ref:a,type:`color`,"aria-label":e,disabled:n,className:`absolute inset-0 size-full cursor-default opacity-0 disabled:pointer-events-none`})]})}function UV({title:e,add:t,children:n}){let r=`inspector-${e.toLowerCase()}`;return(0,G.jsxs)(`section`,{"aria-labelledby":r,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{id:r,className:`text-xs font-semibold`,children:e}),(0,G.jsx)(`button`,{type:`button`,"aria-label":t.label,disabled:t.disabled,onClick:t.onAdd,className:`grid size-5 place-items-center rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50`,children:(0,G.jsx)(Pn,{"aria-hidden":!0,className:`size-[13px]`})})]}),n?(0,G.jsx)(`div`,{className:`mt-2`,children:n}):null]})}function WV({textOnly:e,color:t,backgroundColor:n,tokens:r,theme:i,disabled:a,write:o}){let s=e?`color`:`background-color`,c=e?t:n,l=r[0],u=e=>o({kind:`style`,property:s,value:e});return(0,G.jsx)(UV,{title:`Fill`,add:{label:`Add fill`,disabled:a||c!==null||!l,onAdd:()=>{l&&u(`var(${l.name})`)}},children:c?(0,G.jsx)(VV,{label:`Fill`,value:c,tokens:r,theme:i,disabled:a,onWrite:u}):null})}function GV({name:e,opacity:t,radius:n,disabled:r,write:i}){return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-element`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-element`,className:`mb-2 text-xs font-semibold`,children:`Element`}),(0,G.jsx)(kV,{label:`Name`,className:`mb-1.5`,shown:e,disabled:r,onCommit:e=>i({kind:`attribute`,name:`data-name`,value:e})}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,G.jsx)(kV,{label:`Opacity`,prefix:(0,G.jsx)(xt,{className:`size-1.5 fill-current`}),inset:`pl-[28px]`,shown:`${Math.round(t*100)}%`,disabled:r,onCommit:async e=>{let t=LV(e);return t!==null&&i({kind:`style`,property:`opacity`,value:String(t/100)})}}),(0,G.jsx)(kV,{label:`Corner radius`,prefix:(0,G.jsx)(Xn,{className:`size-3`}),inset:`pl-[28px]`,shown:String(n),disabled:r,onCommit:async e=>{let t=RV(e,`px`);return t!==null&&i({kind:`style`,property:`border-radius`,value:`${t}px`})}})]})]})}function KV({boxShadow:e,shadows:t,theme:n,disabled:r,write:i}){let a=!e||e.value.trim().toLowerCase()===`none`,o=a?null:e.token?PV(t,e.token,n):e.value,s=e=>void i({kind:`style`,property:`box-shadow`,value:e});return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-shadow`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-shadow`,className:`mb-2 text-xs font-semibold`,children:`Shadow`}),(0,G.jsxs)(pB,{children:[(0,G.jsxs)(mB,{"aria-label":`Shadow`,disabled:r,className:`${jV} w-full text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,G.jsx)(qV,{shadow:o}),a?(0,G.jsx)(`span`,{className:`flex-1 text-muted-foreground`,children:`None`}):e.token?(0,G.jsx)(`span`,{className:MV,children:IV(e.token)}):(0,G.jsx)(`span`,{className:`flex-1 truncate`,children:e.value}),!a&&!e.token?(0,G.jsx)(BV,{}):null,(0,G.jsx)(dt,{"aria-hidden":!0,className:`ml-auto size-2.5 shrink-0 text-muted-foreground`})]}),(0,G.jsxs)(wB,{align:`start`,sideOffset:6,className:`w-52`,children:[t.map(e=>(0,G.jsxs)(gB,{className:EB,onClick:()=>s(`var(${e.name})`),children:[(0,G.jsx)(qV,{shadow:e[n]}),IV(e.name)]},e.name)),t.length>0?(0,G.jsx)(SB,{}):null,(0,G.jsx)(gB,{className:EB,onClick:()=>{a||s(`none`)},children:`None`})]})]})]})}function qV({shadow:e}){return(0,G.jsx)(`span`,{"aria-hidden":!0,className:`size-3.5 shrink-0 rounded-[3px] bg-sidebar shadow-[inset_0_0_0_1px_rgba(127,127,127,.3)]`,style:e?{boxShadow:e}:void 0})}var JV=`--border`;function YV({bordered:e,borderColor:t,tokens:n,theme:r,disabled:i,write:a}){let o=n.find(e=>e.name===JV)?.name??n[0]?.name,s=e?t??{value:`currentcolor`,token:null,percent:100}:null;return(0,G.jsx)(UV,{title:`Stroke`,add:{label:`Add stroke`,disabled:i||e||o===void 0,onAdd:()=>{o!==void 0&&a({kind:`style`,property:`border`,value:`1px solid var(${o})`})}},children:s?(0,G.jsx)(VV,{label:`Stroke`,value:s,tokens:n,theme:r,disabled:i,onWrite:e=>a({kind:`style`,property:`border-color`,value:e})}):null})}function XV(e){let[t,n]=(0,y.useState)(null),r=e?.frame,i=e?.index,a=e?.hash,o=e?`${r}:${i}`:null;return(0,y.useEffect)(()=>{if(r===void 0||i===void 0||o===null)return;let e=document.querySelector(`[data-frame="${CSS.escape(r)}"] iframe`);if(!e)return;let t=()=>{let t=e.contentDocument;if(!t||VN(t)!==a)return;let r=BN(t,i),s=t.defaultView;r&&s&&n({at:o,live:ZV(r,s)})};return t(),e.addEventListener(`load`,t),()=>e.removeEventListener(`load`,t)},[r,i,a,o]),t?.at===o?t.live:null}function ZV(e,t){let n=t.getComputedStyle(e),r=e.textContent??``,i=[n.borderTopWidth,n.borderRightWidth,n.borderBottomWidth,n.borderLeftWidth];return{opacity:Number(n.opacity),radius:Math.round(parseFloat(n.borderTopLeftRadius)||0),fontSize:Math.round(parseFloat(n.fontSize)*100)/100,fontWeight:Number(n.fontWeight),textAlign:QV(n.textAlign,n.direction),bordered:i.some(e=>parseFloat(e)>0),holdsText:r.trim()!==``,textOnly:e.childElementCount===0&&r.trim()!==``,text:r}}function QV(e,t){return e===`start`?t===`rtl`?`right`:`left`:e===`end`?t===`rtl`?`left`:`right`:e}function $V(e,t,n,r=eH){let[i,a]=(0,y.useState)(null),o=e===null?null:`${e}:${t??``}`;return(0,y.useEffect)(()=>{if(e===null||o===null)return;let n=!0;return r(e,t).catch(()=>null).then(e=>{n&&e&&a({at:o,styles:e})}),()=>{n=!1}},[e,t,n,o,r]),i?.at===o?i.styles:null}async function eH(e,t){let n=new URLSearchParams({ref:e});t!==void 0&&n.set(`index`,String(t));let r=await(await fetch(`/api/frames/styles?${n}`)).json();return r.ok?r.data:null}function tH({className:e,...t}){return(0,G.jsx)(`textarea`,{"data-slot":`textarea`,className:X(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function nH({text:e,disabled:t,write:n}){let[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(null);a&&a.over!==e&&o(null);let s=a?.over===e?a.value:null,c=(0,y.useRef)(!1),l=()=>{c.current?c.current=!1:r!==null&&(i(null),r!==e&&(o({value:r,over:e}),n({kind:`text`,value:r}).then(e=>{e||o(null)})))};return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-text`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-text`,className:`mb-2 text-xs font-semibold`,children:`Text`}),(0,G.jsx)(tH,{"aria-labelledby":`inspector-text`,value:r??s??e,disabled:t,onChange:e=>{OV(e)||i(e.currentTarget.value)},onBlur:l,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),l()),e.key===`Escape`&&(i(null),c.current=!0,e.currentTarget.blur())},className:`min-h-11 resize-none rounded-md border-0 bg-input px-2 py-1.5 text-xs leading-[1.4] md:text-xs dark:bg-input`})]})}var rH=[{value:`left`,label:`Align text left`,icon:cr},{value:`center`,label:`Align text center`,icon:ir},{value:`right`,label:`Align text right`,icon:or}];function iH({fontSize:e,fontWeight:t,textAlign:n,disabled:r,write:i}){return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-typography`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-typography`,className:`mb-2 text-xs font-semibold`,children:`Typography`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,G.jsx)(kV,{label:`Font size`,prefix:`Size`,inset:`pl-[40px]`,shown:String(e),disabled:r,onCommit:async e=>{let t=RV(e,`px`);return t===null||t===0?!1:i({kind:`style`,property:`font-size`,value:`${t}px`})}}),(0,G.jsx)(kV,{label:`Font weight`,prefix:`Wt`,inset:`pl-[32px]`,shown:String(t),disabled:r,onCommit:async e=>{let t=RV(e,``);return t===null||t<1||t>1e3?!1:i({kind:`style`,property:`font-weight`,value:String(t)})}})]}),(0,G.jsx)(`div`,{className:`mt-1.5 flex w-max gap-0.5 rounded-md bg-input p-0.5`,children:rH.map(({value:e,label:t,icon:a})=>(0,G.jsx)(`button`,{type:`button`,"aria-label":t,"aria-pressed":n===e,disabled:r,onClick:()=>{n!==e&&i({kind:`style`,property:`text-align`,value:e})},className:X(`grid h-[22px] w-7 place-items-center rounded-[5px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50`,n===e&&`bg-sidebar text-foreground`),children:(0,G.jsx)(a,{"aria-hidden":!0,className:`size-[13px]`})},e))})]})}var aH=new Map;function oH(e,t,n,r={}){let i=sH(aH.get(t.frame),e,t,n,r);return aH.set(t.frame,i),i.then(e=>(aH.get(t.frame)===i&&aH.delete(t.frame),e!==null))}async function sH(e,t,n,r,{selection:i=bD,send:a=fetch,notify:o=e=>E_.add({...e,type:`warning`,timeout:0})}){let s=e?await e:void 0;if(s===null)return vD(i,cH),null;let c=s!==void 0&&s.from.includes(n.hash),l=c?s.to:n.hash,u=()=>{};try{let e=await xE([n.frame],`edit`,async()=>{u=mD(n.frame),gD(n.frame,l);try{return await Ml(`/api/frames/edit`,{ref:n.frame,index:n.index,hash:l,change:r},`POST`,a)}catch(e){throw u(),e}});gD(n.frame,e.hash);let o=i.getState().element;return o?.frame===n.frame&&o.index===n.index&&cD(i,t,{...n,hash:e.hash}),u(),yD(i,cH),{from:c?[...s.from,l]:[n.hash],to:e.hash}}catch(e){return e instanceof pE||o({title:`Edit not saved`,description:e instanceof jl?lH(e.message):`The board could not be reached, so nothing was written.`}),u(),vD(i,cH),null}}function cH(e){let t=document.querySelector(`[data-frame="${CSS.escape(e)}"] iframe`)?.contentDocument;return t?VN(t):null}function lH(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return/[.!?]$/.test(t)?t:`${t}.`}function uH({name:e,label:t,onCommit:n,onCancel:r}){let i=(0,y.useRef)(null),a=(0,y.useRef)(!1);(0,y.useEffect)(()=>{i.current?.focus(),i.current?.select()},[]);let o=t=>{if(a.current)return;a.current=!0;let o=i.current?.value.trim()??``;t&&o!==``&&o!==e?n(o):r()};return(0,G.jsx)(`input`,{ref:i,"aria-label":t,defaultValue:e,spellCheck:!1,onClick:e=>e.preventDefault(),onKeyDown:e=>{if(e.key===`Enter`)o(!0);else if(e.key===`Escape`)o(!1);else return;e.preventDefault(),e.stopPropagation()},onBlur:()=>o(!0),className:`-ml-1.5 h-[22px] min-w-0 flex-1 rounded-[5px] bg-background px-1.5 text-foreground ring-[1.5px] ring-primary outline-none selection:bg-primary/45`})}var dH=[{key:`x`,letter:`X`,label:`X position`},{key:`y`,letter:`Y`,label:`Y position`},{key:`width`,letter:`W`,label:`Width`},{key:`height`,letter:`H`,label:`Height`}];function fH({frames:e,page:t,named:n=!0,write:r=IE,calls:i}){let a=Z(e=>e.canWrite),o=WF(`inspector`),[s]=e;if(!s)return null;let c=e.length>1,l=e.some(e=>e.locked),u=(n,i)=>{let a={},o={};for(let{ref:t,box:r}of e){let e={...r,[n]:i};e[n]!==r[n]&&(a[t]=e,o[t]=r)}r(t,a,o)};return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-frame`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-frame`,className:`mb-2 text-xs font-semibold`,children:c?`${e.length} frames`:`Frame`}),c||!n?null:o===s.ref?(0,G.jsx)(`div`,{className:`mb-1.5 flex h-[26px] items-center pl-1.5`,children:(0,G.jsx)(uH,{name:s.name,label:`Rename frame ${s.name}`,onCommit:e=>{KF(),qF(s,e,i)},onCancel:KF})}):(0,G.jsx)(`button`,{type:`button`,"aria-label":`Rename frame ${s.name}`,disabled:!a,onClick:()=>GF(s.ref,`inspector`),className:`mb-1.5 block h-[26px] w-full truncate rounded-md bg-input px-2 text-left text-xs outline-none hover:ring-1 hover:ring-border focus-visible:ring-2 focus-visible:ring-ring/50 disabled:hover:ring-0`,children:s.name}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:dH.map(({key:t,letter:n,label:r})=>(0,G.jsx)(pH,{letter:n,label:r,value:mH(e.map(({box:e})=>e[t])),min:t===`width`||t===`height`?1:void 0,disabled:!a||l,onCommit:e=>u(t,e)},t))})]})}function pH({letter:e,label:t,value:n,min:r,disabled:i,onCommit:a}){let o=n===null?`Mixed`:String(n),[s,c]=(0,y.useState)(null),l=()=>{if(s===null)return;c(null);let e=Number(s.trim());s.trim()!==o&&Number.isInteger(e)&&a(r===void 0?e:Math.max(r,e))};return(0,G.jsxs)(`label`,{className:`relative block`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2 -translate-y-1/2 text-xs text-faint`,children:e}),(0,G.jsx)(DV,{"aria-label":t,inputMode:`numeric`,className:`pl-[26px]`,value:s??o,disabled:i,onFocus:e=>e.currentTarget.select(),onChange:e=>c(e.currentTarget.value),onBlur:l,onKeyDown:e=>{e.key===`Enter`&&l(),e.key===`Escape`&&(c(null),e.currentTarget.blur())}})]})}function mH(e){let[t]=e;return t!==void 0&&e.every(e=>e===t)?t:null}function hH({colors:e,tokens:t,theme:n}){return e.length===0?null:(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-selection-colors`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-selection-colors`,className:`mb-2 text-xs font-semibold`,children:`Selection colors`}),(0,G.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.map(e=>(0,G.jsxs)(`li`,{className:jV,children:[(0,G.jsx)(zV,{color:FV(e,t,n)}),e.token?(0,G.jsx)(`span`,{className:MV,children:IV(e.token)}):(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate tabular-nums`,children:e.value.replace(/^#/,``)}),(0,G.jsxs)(`span`,{className:`ml-auto text-muted-foreground tabular-nums`,children:[e.percent,`%`]}),e.token?(0,G.jsx)($t,{role:`img`,"aria-label":`Token`,className:`size-[13px] shrink-0 text-muted-foreground`}):(0,G.jsx)(BV,{})]},`${e.token??e.value}:${e.percent}`))})]})}function gH(){let e=iz()??null,t=aD(e=>e.mode===`play`),n=aD(e=>e.mode===`edit`&&e.tool===`frame`),r=Z(e=>e.listeners),i=Z(e=>e.claims),a=xD(e=>e.page),o=xD(e=>e.frames),s=xD(e=>e.element??null),c=jE(Z(e=>e.board?.projects.flatMap(e=>e.pages).find(e=>e.ref===a))?.frames.filter(e=>o.includes(e.ref))??[]),l=s&&c.length===1?s:null;return(0,G.jsxs)(`aside`,{"aria-label":`Inspector`,className:`flex h-full min-w-0 flex-col overflow-y-auto bg-sidebar text-body text-sidebar-foreground`,children:[(0,G.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between border-b border-sidebar-border px-3`,children:[(0,G.jsxs)(`span`,{className:`flex items-center`,children:[(0,G.jsx)(OB,{name:e}),(0,G.jsx)(rV,{listeners:r,claims:i})]}),(0,G.jsx)(NB,{})]}),n?(0,G.jsx)(SH,{}):a&&c.length>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fH,{page:a,frames:c,named:!l}),c.length>1?(0,G.jsx)(cV,{}):null,l?(0,G.jsx)(yH,{page:a,element:l}):(0,G.jsx)(bH,{frames:c})]}):(0,G.jsx)(`div`,{className:`px-3 pt-2.5 pb-3 text-muted-foreground`,children:t?(0,G.jsx)(`p`,{children:`Playing. Nothing selects while frames take the clicks.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{children:`Select a frame to see its details.`}),(0,G.jsx)(`p`,{className:`mt-4`,children:`Click a frame, or drag on the canvas to select several.`})]})})]})}var _H=`--shadow`;function vH(e){let t=iV(e.split(`/`)[0]??``)?.tokens??[];return{colors:t.filter(e=>e.group===`color`&&!e.name.startsWith(_H)),shadows:t.filter(e=>e.name.startsWith(_H))}}function yH({page:e,element:t}){let n=Z(e=>e.canWrite),r=nv(t.frame),i=XV(t),a=$V(t.frame,t.index,t.hash),o=PP(t.frame),{colors:s,shadows:c}=vH(t.frame),l=o?.status===`ready`?o.tree.elements.find(({index:e})=>e===t.index):void 0;if(!i)return(0,G.jsx)(`p`,{className:`px-3 pt-2.5 pb-3 text-muted-foreground`,children:`The element’s details show once its frame is on screen.`});let u=!n,d=n=>oH(e,t,n),f=a?.element;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(GV,{name:l?.name??``,opacity:i.opacity,radius:i.radius,disabled:u,write:d}),i.holdsText?(0,G.jsx)(iH,{fontSize:i.fontSize,fontWeight:i.fontWeight,textAlign:i.textAlign,disabled:u,write:d}):null,(0,G.jsx)(WV,{textOnly:i.textOnly,color:f?.color??null,backgroundColor:f?.backgroundColor??null,tokens:s,theme:r,disabled:u,write:d}),i.textOnly?(0,G.jsx)(nH,{text:i.text,disabled:u,write:d}):null,(0,G.jsx)(YV,{bordered:i.bordered,borderColor:f?.borderColor??null,tokens:s,theme:r,disabled:u,write:d}),(0,G.jsx)(KV,{boxShadow:f?.boxShadow??null,shadows:c,theme:r,disabled:u,write:d}),(0,G.jsx)(hH,{colors:a?.colors??[],tokens:s,theme:r})]})}function bH({frames:e}){let[t]=e,n=nv(t?.ref??``),{colors:r}=vH(t?.ref??``),i=e.map(e=>e.ref).join(`
65
65
  `),a=Z(e=>i.split(`
66
66
  `).map(t=>e.reloads[t]??0).join(`:`)),[o,s]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let e=!0;return Promise.all(i.split(`
67
- `).map(e=>$V(e).catch(()=>null))).then(t=>{if(!e)return;let n=new Map;for(let e of t.flatMap(e=>e?.colors??[])){let t=`${e.token??e.value.toLowerCase()}:${e.percent}`;n.has(t)||n.set(t,e)}s({refs:i,colors:[...n.values()]})}),()=>{e=!1}},[i,a]),(0,G.jsx)(mH,{colors:o?.refs===i?o.colors:[],tokens:r,theme:n})}var bH=[{preset:`phone`,label:`Phone`,icon:Jn},{preset:`tablet`,label:`Tablet`,icon:nr},{preset:`desktop`,label:`Desktop`,icon:gn}];function xH(){let e=$F();return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-presets`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-presets`,className:`mb-2 text-xs font-semibold`,children:`Frame`}),(0,G.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":`inspector-presets`,className:`-mx-1.5 flex flex-col`,children:bH.map(({preset:t,label:n,icon:r})=>{let{width:i,height:a}=XF[t];return(0,G.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t===e,onClick:()=>eI(t),className:X(`flex h-[26px] items-center gap-1.5 rounded-md px-1.5 text-left outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/50`,t===e&&`bg-accent`),children:[(0,G.jsx)(r,{"aria-hidden":!0,className:`size-[13px] text-muted-foreground`,strokeWidth:1.6}),(0,G.jsx)(`span`,{className:`flex-1`,children:n}),(0,G.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[i,` × `,a]})]},t)})}),(0,G.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:`Click on the canvas to place it.`})]})}var SH=y.createContext(void 0);function CH(){let e=y.useContext(SH);if(e===void 0)throw Error(Ds(64));return e}var wH=`data-activation-direction`,TH={tabActivationDirection:e=>({[wH]:e})},EH=y.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,style:c,...l}=e,u=e.defaultValue!==void 0,d=y.useRef([]),[f,p]=y.useState(()=>new Map),[m,h]=hI({controlled:s,default:r,name:`Tabs`,state:`value`}),g=s!==void 0,[_,v]=y.useState(()=>new Map),b=y.useRef(void 0),x=y.useCallback(e=>DH(_,e),[_]),[S,C]=y.useState(()=>({previousValue:m,tabActivationDirection:`none`})),{previousValue:w,tabActivationDirection:T}=S,E=T,D=!1;w!==m&&(E=OH(w,m,a,_),D=w!=null&&m!=null&&x(m)==null);let O=D?w:m,k=w!==O||T!==E;Y(()=>{k&&C({previousValue:O,tabActivationDirection:E})},[O,k,E]);let A=J((e,t)=>{t.activationDirection=OH(m,e,a,_),i?.(e,t),!t.isCanceled&&h(()=>e)}),j=J((e,t)=>{i?.(e,jp(t,void 0,void 0,{activationDirection:`none`}))}),M=J((e,t)=>(p(n=>{let r=new Map(n);return r.set(e,t),r}),()=>{p(n=>{if(n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})})),N=y.useCallback(e=>f.get(e),[f]),P=y.useCallback(e=>{for(let t of _.values())if(e===t.value)return t.id},[_]),F=y.useMemo(()=>({getTabElementBySelectedValue:x,getTabIdByPanelValue:P,getTabPanelIdByValue:N,onValueChange:A,orientation:a,registerMountedTabPanel:M,setTabMap:v,tabActivationDirection:E,value:m}),[x,P,N,A,a,M,v,E,m]),I=y.useMemo(()=>{for(let e of _.values())if(e.value===m)return e},[_,m]),L=y.useMemo(()=>{for(let e of _.values())if(!e.disabled)return e.value},[_]),R=y.useRef(!u),z=y.useRef(r),B=y.useRef(u),ee=y.useRef(!1);Y(()=>{if(g)return;function e(e,t){h(()=>e),C({previousValue:e,tabActivationDirection:`none`}),j(e,t),R.current=!1}if(_.size===0){ee.current&&m!==null&&!b.current?.isConnected&&e(null,Jp);return}ee.current=!0,b.current=_.keys().next().value;let t=I?.disabled,n=I==null&&m!==null;if(!t&&m===z.current&&(B.current=!1),B.current&&t&&m===z.current)return;let r=R.current;if(t||n){let n=L??null;if(m===n){R.current=!1;return}let i=Jp;r?i=Yp:t&&(i=qp),e(n,i)}else r&&I!=null&&(j(m,Yp),R.current=!1)},[L,g,j,I,h,_,m]);let te=Zs(`div`,e,{state:{orientation:a,tabActivationDirection:E},ref:t,props:l,stateAttributesMapping:TH});return(0,G.jsx)(SH.Provider,{value:F,children:(0,G.jsx)(uL,{elementsRef:d,children:te})})});function DH(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function OH(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=DH(r,e),c=DH(r,t);if(s==null||c==null)return s!==c&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?t>e?o:a:`none`;let l=s.getBoundingClientRect()[i],u=c.getBoundingClientRect()[i];return u<l?a:u>l?o:`none`}var kH=`data-composite-item-active`,AH=y.createContext(void 0);function jH(){let e=y.useContext(AH);if(e===void 0)throw Error(Ds(65));return e}var MH=y.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,style:c,...l}=e,{value:u,getTabPanelIdByValue:d,onValueChange:f,orientation:p,tabActivationDirection:m}=CH(),{activateOnFocus:h,registerTabResizeObserverElement:g,tabsListElement:_}=jH(),{highlightedIndex:v,onHighlightedIndexChange:b}=ks(),x=OI(o),{compositeProps:S,compositeRef:C,index:w}=lR({metadata:y.useMemo(()=>({disabled:r,id:x,value:a}),[r,x,a])}),T=a===u,E=y.useRef(!1),D=y.useRef(null),O=J(e=>{D.current?.(),D.current=e?g(e):null});Y(()=>{if(E.current){E.current=!1;return}if(!(T&&w>-1&&v!==w))return;let e=_;if(e!=null){let t=Nu(js(e));if(t&&Q(e,t))return}r||b(w)},[T,w,v,b,r,_]);let{getButtonProps:k,buttonRef:A}=Ns({disabled:r,native:s,focusableWhenDisabled:!0}),j=d(a),M=y.useRef(!1),N=y.useRef(!1);function P(e){f(a,jp(Np,e.nativeEvent,void 0,{activationDirection:`none`}))}function F(e){T||r||P(e)}function I(e){T||r||h&&(!M.current||N.current)&&P(e)}function L(e){if(T||r)return;M.current=!0,N.current=e.button===0;let t=js(e.currentTarget);function n(){M.current=!1,N.current=!1,t.removeEventListener(`pointerup`,n),t.removeEventListener(`pointercancel`,n)}t.addEventListener(`pointerup`,n),t.addEventListener(`pointercancel`,n)}return Zs(`button`,e,{state:{disabled:r,active:T,orientation:p,tabActivationDirection:m},ref:[t,A,C,O],props:[S,{role:`tab`,"aria-controls":j,"aria-selected":T,id:x,onClick:F,onFocus:I,onPointerDown:L,[kH]:T?``:void 0,onKeyDownCapture(){E.current=!0}},l,k],stateAttributesMapping:TH})}),NH=`data-index`,PH={...TH,...Ku},FH=y.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:a=!1,style:o,...s}=e,{value:c,getTabIdByPanelValue:l,orientation:u,tabActivationDirection:d,registerMountedTabPanel:f}=CH(),p=OI(),{ref:m,index:h}=DI(),g=r===c,{mounted:_,transitionStatus:v,setMounted:b}=th(g),x=!_,S=l(r),C={hidden:x,orientation:u,tabActivationDirection:d,transitionStatus:v},w=y.useRef(null),T=Zs(`div`,e,{state:C,ref:[t,m,w],props:[{"aria-labelledby":S,hidden:x,id:p,role:`tabpanel`,tabIndex:g?0:-1,inert:Bf(!g),[NH]:h},s],stateAttributesMapping:PH});return Yf({open:g,ref:w,onComplete(){g||b(!1)}}),Y(()=>{if(!(p==null||x&&!a))return f(r,p)},[x,a,r,p,f]),a||_?T:null});function IH(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=Ks}=e,[p,m]=y.useState(0),h=r!=null,g=y.useRef(null),_=Is(g,c),v=y.useRef([]),b=y.useRef(!1),x=y.useRef(null),S=o??p,C=J((e,t=!1)=>{if(x.current=v.current[e]??null,(s??m)(e),t){let t=v.current[e];YI(g.current,t,a,n)}}),w=J(e=>{if(e.size===0)return;if(b.current){let e=v.current,t=e.indexOf(x.current);if(t===-1){let t=e[S];!t||nf(e,S,d)?C(LH(e,d)):x.current=t}else t!==S&&C(t);return}b.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)C(i);else if(nf(t,S,d)){let e=tf(t,{disabledIndices:d});Zd(t,e)||C(e)}YI(g.current,r,a,n)});Y(()=>{if(d==null||o!=null||!b.current)return;let e=v.current;if(nf(e,S,d)){let t=tf(e,{disabledIndices:d});Zd(e,t)||C(t)}},[d,o,S,v,C]);let T=J((e,t,n)=>i?i(e,t,n,v):n),E=J(e=>{let o=e.key===`Home`||e.key===`End`;if(!GI.has(e.key)||!l&&o||RH(e,f)||!g.current)return;let s=a===`rtl`,c=s?UI:WI,p=s?WI:UI,m=n===`vertical`?HI:c,_=n===`vertical`?VI:p,y=Fu(e.nativeEvent);if(y!=null&&JI(y)&&!vR(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let b=S,x=Qd(v,d),w=$d(v,d);r!=null&&(b=r({disabledIndices:d,elementsRef:v,event:e,highlightedIndex:S,loopFocus:t,maxIndex:w,minIndex:x,onLoop:T,orientation:n,rtl:s}));let E=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,D=n!==`vertical`&&e.key===p||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?b=x:e.key===`End`&&(b=w)),b===S&&(E||D)&&(t&&b===w&&E?(b=x,i&&(b=i(e,S,b,v))):t&&b===x&&D?(b=w,i&&(b=i(e,S,b,v))):b=tf(v.current,{startingIndex:b,decrement:D,disabledIndices:d})),b!==S&&!Zd(v.current,b)&&(u&&e.stopPropagation(),(h||o||E||D)&&e.preventDefault(),C(b,!0),queueMicrotask(()=>{v.current[b]?.focus()}))});return{props:{ref:_,onFocus(e){let t=g.current,n=Fu(e.nativeEvent);t&&n!=null&&JI(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:E},highlightedIndex:S,onHighlightedIndexChange:C,elementsRef:v,onMapChange:w,relayKeyboardEvent:E}}function LH(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!nf(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function RH(e,t){for(let n of KI)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function zH(e){let{render:t,className:n,style:r,refs:i=Ks,props:a=Ks,state:o=qs,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:b,highlightItemOnHover:x=!1,tag:S=`div`,...C}=e,{props:w,highlightedIndex:T,onHighlightedIndexChange:E,elementsRef:D,onMapChange:O,relayKeyboardEvent:k}=IH({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:a_(),disabledIndices:v,modifierKeys:b}),A=Zs(S,e,{state:o,ref:i,props:[w,...a,C],stateAttributesMapping:s}),j=y.useMemo(()=>({highlightedIndex:T,onHighlightedIndexChange:E,highlightItemOnHover:x,relayKeyboardEvent:k}),[T,E,x,k]);return(0,G.jsx)(Os.Provider,{value:j,children:(0,G.jsx)(uL,{elementsRef:D,onMapChange:e=>{h?.(e),O(e)},children:A})})}var BH=y.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,style:o,...s}=e,{orientation:c,setTabMap:l,tabActivationDirection:u}=CH(),[d,f]=y.useState(0),[p,m]=y.useState(null),h=y.useRef(new Set),g=y.useRef(new Set),_=y.useRef(null);Y(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{h.current.forEach(e=>{e()})});return _.current=e,p&&e.observe(p),g.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),_.current=null}},[p]);let v=J(e=>(h.current.add(e),()=>{h.current.delete(e)})),b=J(e=>(g.current.add(e),_.current?.observe(e),()=>{g.current.delete(e),_.current?.unobserve(e)})),x={orientation:c,tabActivationDirection:u},S={"aria-orientation":c===`vertical`?`vertical`:void 0,role:`tablist`},C=y.useMemo(()=>({activateOnFocus:n,registerIndicatorUpdateListener:v,registerTabResizeObserverElement:b,tabsListElement:p}),[n,v,b,p]);return(0,G.jsx)(AH.Provider,{value:C,children:(0,G.jsx)(zH,{render:a,className:r,style:o,state:x,refs:[t,m],props:[S,s],stateAttributesMapping:TH,highlightedIndex:d,enableHomeAndEndKeys:!0,loopFocus:i,orientation:c,onHighlightedIndexChange:f,onMapChange:l,disabledIndices:Ks})})});function VH({className:e,orientation:t=`horizontal`,...n}){return(0,G.jsx)(EH,{"data-slot":`tabs`,"data-orientation":t,className:X(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var HH=lc(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function UH({className:e,variant:t=`default`,...n}){return(0,G.jsx)(BH,{"data-slot":`tabs-list`,"data-variant":t,className:X(HH({variant:t}),e),...n})}function WH({className:e,...t}){return(0,G.jsx)(MH,{"data-slot":`tabs-trigger`,className:X(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function GH({className:e,...t}){return(0,G.jsx)(FH,{"data-slot":`tabs-content`,className:X(`flex-1 text-sm outline-none`,e),...t})}var KH=null;function qH(e,t){let[n=``,r=``]=e.split(`/`),i=z(n,r);if(KH?.(),KH=null,t(),JH(i)&&OD.attached()){YH();return}let a=OD.onAttach(()=>{OD.attached()&&(a(),KH=null,YH())});KH=a,F(i)}function JH(e){return decodeURIComponent(location.pathname)===decodeURIComponent(e)}function YH(){we(`view.zoomToSelection`)?.run()}function XH(e,t,n=bD,r=sH){let i=`${e}/${t.page}`,{index:a,hash:o}=t;qH(i,()=>{let e=r(t.ref),s=e!==null&&e!==o&&!_D(t.ref,e);a===null||o===null||s?sD(n,i,[t.ref]):cD(n,i,{frame:t.ref,index:a,hash:o})})}function ZH(e,t,n,r=$H){let[i,a]=(0,y.useState)(null),o=(0,y.useRef)(0),s=(0,y.useRef)(n);(0,y.useEffect)(()=>{s.current=n},[n]);let c=Z(t=>QH(t.reloads,e)),l=t.trim()===``,u=`${c}\n${e}\n${t}`;if((0,y.useEffect)(()=>{let n=++o.current;if(l)return;let i=setTimeout(()=>{r(e,t).then(e=>{n===o.current&&a({key:u,status:`ready`,result:e,lead:s.current})},e=>{if(n!==o.current)return;let t=e instanceof Error?e.message:String(e);a({key:u,status:`refused`,message:t})})},120);return()=>clearTimeout(i)},[e,t,l,u,r]),l)return{status:`idle`};if(i?.status===`ready`){let{result:e,lead:t}=i;return{status:`ready`,result:e,lead:t,updating:i.key!==u}}return i?.status===`refused`&&i.key===u?i:{status:`loading`}}function QH(e,t){let n=0;for(let[r,i]of Object.entries(e))r.startsWith(`${t}/`)&&(n+=i);return n}async function $H(e,t,n=fetch){let r=await n(`/api/find?${new URLSearchParams({project:e,q:t})}`),i=await r.json().catch(()=>null);if(!i)throw Error(`The board answered ${r.status}.`);if(!i.ok)throw Error(i.error.message);return i.data}var eU=[{value:`all`,label:`All`},{value:`frame`,label:`Frames`},{value:`element`,label:`Elements`},{value:`text`,label:`Text`}],tU={frame:Xn,element:In,text:mr},nU={frame:`frame`,element:`element`,text:`text`};function rU({project:e,page:t,load:n,pick:r=XH}){let[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(`all`),[c,l]=(0,y.useState)(null),u=(0,y.useRef)(null),d=qB(e=>e.focusRequest),f=ZH(e,i,t,n),p=(0,y.useId)();(0,y.useEffect)(()=>{u.current?.focus(),u.current?.select()},[d]);let m=sU(f.status===`ready`?f.result.hits.filter(e=>o===`all`||e.kind===o):[],f.status===`ready`?f.lead:``),h=m.flatMap(e=>e.hits),g=h.find(e=>cU(e)===c)??h[0]??null,_=e=>`${p}-${cU(e)}`,v=t=>{l(cU(t)),r(e,t)};return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col text-xs`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),YB())},children:[(0,G.jsxs)(`div`,{className:`m-2 flex shrink-0 items-center gap-1.5`,children:[(0,G.jsxs)(`label`,{className:`flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-[7px] bg-muted px-2 focus-within:ring-[1.5px] focus-within:ring-primary`,children:[(0,G.jsx)(Kn,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,G.jsx)(`input`,{ref:u,role:`combobox`,"aria-label":`Find in ${e}`,"aria-expanded":h.length>0,"aria-controls":p,"aria-autocomplete":`list`,"aria-activedescendant":g?_(g):void 0,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),h.length===0)return;let t=g?h.indexOf(g):-1,n=e.key===`ArrowDown`?1:-1,r=h[(t+n+h.length)%h.length];r&&l(cU(r))}else e.key===`Enter`&&g&&(e.preventDefault(),v(g))},spellCheck:!1,autoComplete:`off`,className:`min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none`})]}),(0,G.jsx)(`button`,{type:`button`,"aria-label":i===``?`Close find`:`Clear the search`,onClick:()=>{i===``?YB():(a(``),u.current?.focus())},className:`grid size-[26px] shrink-0 place-items-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 active:bg-accent`,children:(0,G.jsx)(br,{"aria-hidden":!0,className:`size-3.5`})})]}),(0,G.jsx)(`div`,{role:`group`,"aria-label":`Show`,className:`flex shrink-0 gap-1 px-2 pb-1.5`,children:eU.map(e=>(0,G.jsx)(`button`,{type:`button`,"aria-pressed":o===e.value,onClick:()=>s(e.value),className:X(`flex h-[22px] items-center rounded-full px-2 text-[11px] outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,o===e.value?`bg-foreground text-sidebar`:`bg-muted text-muted-foreground hover:bg-accent hover:text-foreground`),children:e.label},e.value))}),(0,G.jsx)(`div`,{id:p,role:`listbox`,"aria-label":`Matches`,"aria-busy":f.status===`ready`&&f.updating,className:X(`min-h-0 overflow-y-auto pb-1`,f.status===`ready`&&f.updating&&`opacity-60`),children:m.map(e=>(0,G.jsxs)(`div`,{role:`group`,"aria-labelledby":`${p}-${e.page}`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between px-3 pt-2 pb-0.5 text-[11px] font-semibold text-faint`,children:[(0,G.jsx)(`span`,{id:`${p}-${e.page}`,children:e.page}),(0,G.jsx)(`span`,{children:e.hits.length})]}),e.hits.map(e=>(0,G.jsx)(iU,{id:_(e),hit:e,query:i,active:e===g,onPick:()=>v(e)},cU(e)))]},e.page))}),(0,G.jsx)(aU,{answer:f,project:e,shown:h.length,filter:o,onShowAll:()=>s(`all`)}),(0,G.jsx)(`p`,{className:`shrink-0 px-3 pt-2 pb-3 text-[11px] text-faint`,children:`Esc goes back to the layers`})]})}function iU({id:e,hit:t,query:n,active:r,onPick:i}){let a=tU[t.kind],o=t.kind===`text`?`Text in ${t.frame}`:(0,G.jsx)(oU,{text:t.name,query:n}),s=t.kind===`text`?(0,G.jsxs)(G.Fragment,{children:[`“`,(0,G.jsx)(oU,{text:t.snippet??``,query:n}),`”`]}):t.kind===`element`?`in ${t.frame}`:nU.frame;return(0,G.jsxs)(`div`,{id:e,role:`option`,"aria-selected":r,onMouseDown:e=>e.preventDefault(),onClick:i,className:X(`mx-1.5 flex items-start gap-2 rounded-md px-2 py-[5px] text-foreground hover:bg-sidebar-accent`,r&&`bg-accent`),children:[(0,G.jsx)(a,{"aria-hidden":!0,className:`mt-px size-[13px] shrink-0 text-muted-foreground`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate`,children:o}),(0,G.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:s})]})]})}function aU({answer:e,project:t,shown:n,filter:r,onShowAll:i}){let a=`shrink-0 px-3 pt-2 text-[11px]`;if(e.status===`idle`)return(0,G.jsxs)(`p`,{className:X(a,`text-muted-foreground`),children:[`Type to find frames, elements, and text across every page of `,t,`.`]});if(e.status===`loading`)return null;if(e.status===`refused`)return(0,G.jsx)(`p`,{role:`alert`,className:X(a,`text-destructive`),children:e.message});let{hits:o,truncated:s,query:c}=e.result;return o.length===0?(0,G.jsxs)(`p`,{className:X(a,`text-muted-foreground`),children:[`Nothing in `,t,` matches “`,c.trim(),`”.`]}):n===0&&r!==`all`?(0,G.jsxs)(`p`,{className:X(a,`text-muted-foreground`),children:[s?`The first ${o.length} matches hold no ${nU[r]}. Type more to narrow them.`:`No ${nU[r]} matches.`,` `,(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-foreground underline underline-offset-2 outline-none hover:text-primary focus-visible:ring-3 focus-visible:ring-ring/50`,children:`Show all`})]}):s?(0,G.jsxs)(`p`,{className:X(a,`text-muted-foreground`),children:[`Showing the first `,o.length,` matches. Type more to narrow them.`]}):null}function oU({text:e,query:t}){let n=t.trim().toLowerCase(),r=n===``?-1:e.toLowerCase().indexOf(n);return r===-1?(0,G.jsx)(G.Fragment,{children:e}):(0,G.jsxs)(G.Fragment,{children:[e.slice(0,r),(0,G.jsx)(`mark`,{className:`rounded-[2px] bg-primary/35 text-foreground`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}function sU(e,t){let n=[];for(let t of e){let e=n.find(e=>e.page===t.page);e?e.hits.push(t):n.push({page:t.page,hits:[t]})}let r=n.findIndex(e=>e.page===t);return r>0&&n.unshift(...n.splice(r,1)),n}function cU(e){return`${e.kind}:${e.ref}:${e.index??``}`}function lU(e){let t=(0,y.useRef)(!1);return{onKeyDown:e=>{if(!(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey))return;e.preventDefault(),e.stopPropagation(),t.current=!0;let n=e.currentTarget.getBoundingClientRect();e.currentTarget.dispatchEvent(new MouseEvent(`contextmenu`,{bubbles:!0,cancelable:!0,clientX:n.left+n.width/2,clientY:n.top+n.height/2}))},onOpenChangeComplete:n=>{n&&t.current&&(t.current=!1,e.current?.querySelector(`[role="menuitem"]:not([aria-disabled="true"])`)?.focus())}}}var uU=[`view.zoomToSelection`,`frame.duplicate`,`frame.hide`,`frame.lock`,`frame.delete`];function dU({frame:e,page:t,trigger:n}){let r=Ce(uU),[i,a,o,s,c]=xD(n=>n.page===t&&!n.element&&n.frames.includes(e.ref))?r:r.map(()=>void 0),l=Z(e=>e.canWrite),u=(0,y.useRef)(null),d=lU(u);return(0,G.jsxs)(ER,{onOpenChange:n=>{if(!n||e.hidden||iD.getState().mode!==`edit`)return;let{page:r,frames:i,element:a}=bD.getState();(a||r!==t||!i.includes(e.ref))&&sD(bD,t,[e.ref])},onOpenChangeComplete:d.onOpenChangeComplete,children:[(0,G.jsx)(DR,{render:n,onKeyDown:d.onKeyDown}),(0,G.jsxs)(OR,{ref:u,className:`w-55`,children:[(0,G.jsxs)(kR,{children:[(0,G.jsx)(IR,{children:`Frame in layers`}),(0,G.jsx)(PR,{action:i,children:`Zoom to frame`}),(0,G.jsx)(PR,{action:{id:`layers.rename`,label:`Rename`,group:`frame`,enabled:()=>l&&iD.getState().mode===`edit`,run:()=>GF(e.ref,`layers`)}}),(0,G.jsx)(PR,{action:a,children:`Duplicate`}),(0,G.jsx)(PR,{action:o,children:`Hide`}),(0,G.jsx)(PR,{action:s,children:s?.checked?.()?`Unlock`:`Lock`})]}),(0,G.jsx)(MR,{}),(0,G.jsx)(FR,{action:c})]})]})}function fU({page:e,element:t,trigger:n}){let r=(0,y.useRef)(null),i=lU(r);return(0,G.jsxs)(ER,{onOpenChange:n=>{n&&cD(bD,e,t)},onOpenChangeComplete:i.onOpenChangeComplete,children:[(0,G.jsx)(DR,{render:n,onKeyDown:i.onKeyDown}),(0,G.jsx)(OR,{ref:r,className:`w-[230px]`,children:(0,G.jsx)(WR,{noteable:!1})})]})}function pU({edge:e}){return e===null?null:(0,G.jsx)(`span`,{"aria-hidden":!0,className:X(`pointer-events-none absolute right-1.5 left-5 z-10 h-0.5 rounded-[1px] bg-primary`,`before:absolute before:-top-[3px] before:-left-[5px] before:size-2 before:rounded-full before:border-2 before:border-primary before:bg-sidebar before:content-['']`,e===`top`?`-top-px`:`-bottom-px`)})}var mU=14,hU=8;function gU({frame:e,page:t,selected:n,frameSelected:r,isOpen:i,toggle:a}){let o=PP(e.ref);if(!o||o.status===`loading`)return(0,G.jsx)(_U,{depth:1,children:`Reading elements`});if(o.status===`refused`)return(0,G.jsx)(_U,{depth:1,title:o.message,children:`This frame cannot be addressed`});let{tree:s}=o,c=vU(s.elements,i);if(c.length===0)return(0,G.jsx)(_U,{depth:1,children:`No elements`});let l=new Set(s.elements.map(e=>e.parent));return(0,G.jsx)(`ul`,{"aria-label":`Elements of ${e.name}`,children:c.map(({element:o,depth:c})=>{let u=i(o.index),d=o.index===n,f=o.textOnly?mr:In;return(0,G.jsx)(fU,{page:t,element:{frame:e.ref,index:o.index,hash:s.hash},trigger:(0,G.jsxs)(`li`,{className:X(`flex h-[26px] items-center gap-1.5 pr-2 text-foreground`,d?`bg-primary/26`:r?`bg-primary/13`:n===null?`hover:bg-accent`:`bg-primary/7`),style:{paddingLeft:hU+c*mU},children:[l.has(o.index)?(0,G.jsx)(`button`,{type:`button`,"aria-label":`${u?`Hide`:`Show`} what ${o.name} holds`,"aria-expanded":u,onClick:()=>a(o.index),className:`grid w-2.5 shrink-0 place-items-center text-faint outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:u?(0,G.jsx)(dt,{"aria-hidden":!0,className:`size-2.5`}):(0,G.jsx)(pt,{"aria-hidden":!0,className:`size-2.5`})}):(0,G.jsx)(`span`,{"aria-hidden":!0,className:`w-2.5 shrink-0`}),(0,G.jsxs)(`button`,{type:`button`,"aria-current":d?`true`:void 0,onClick:()=>cD(bD,t,{frame:e.ref,index:o.index,hash:s.hash}),className:`flex min-w-0 flex-1 items-center gap-1.5 self-stretch text-left outline-none focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset`,children:[(0,G.jsx)(f,{"aria-hidden":!0,className:X(`size-[13px] shrink-0`,d?`text-primary`:`text-muted-foreground`)}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:o.name,children:o.name})]})]})},o.index)})})}function _U({depth:e,title:t,children:n}){return(0,G.jsx)(`p`,{title:t,className:`flex h-[26px] items-center truncate pr-2 text-faint`,style:{paddingLeft:hU+e*mU+16},children:n})}function vU(e,t){let n=new Map,r=[];for(let i of e){if(i.parent===null){n.set(i.index,1),r.push({element:i,depth:1});continue}let e=n.get(i.parent);e!==void 0&&t(i.parent)&&(n.set(i.index,e+1),r.push({element:i,depth:e+1}))}return r}function yU(e){if(Array.isArray(e))return e}function bU(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function xU(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function SU(e,t){if(e){if(typeof e==`string`)return xU(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?xU(e,t):void 0}}function CU(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
68
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wU(e,t){return yU(e)||bU(e,t)||SU(e,t)||CU()}var TU=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.bind=void 0;function t(e,t){var n=t.type,r=t.listener,i=t.options;return e.addEventListener(n,r,i),function(){e.removeEventListener(n,r,i)}}e.bind=t})),EU=o(((e,t,n)=>{var r=n&&n.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.bindAll=void 0;var i=TU();function a(e){if(e!==void 0)return typeof e==`boolean`?{capture:e}:e}function o(e,t){return t==null?e:r(r({},e),{options:r(r({},a(t)),a(e.options))})}function s(e,t,n){var r=t.map(function(t){var r=o(t,n);return(0,i.bind)(e,r)});return function(){r.forEach(function(e){return e()})}}e.bindAll=s})),DU=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.bindAll=e.bind=void 0;var t=TU();Object.defineProperty(e,"bind",{enumerable:!0,get:function(){return t.bind}});var n=EU();Object.defineProperty(e,"bindAll",{enumerable:!0,get:function(){return n.bindAll}})}))(),OU=`data-pdnd-honey-pot`;function kU(e){return e instanceof Element&&e.hasAttribute(`data-pdnd-honey-pot`)}function AU(e){var t=wU(document.elementsFromPoint(e.x,e.y),2),n=t[0],r=t[1];return n?kU(n)?r??null:n:null}function jU(e){"@babel/helpers - typeof";return jU=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},jU(e)}function MU(e,t){if(jU(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(jU(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function NU(e){var t=MU(e,`string`);return jU(t)==`symbol`?t:t+``}function PU(e,t,n){return(t=NU(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var FU=2147483647,IU={inset:`unset`,border:`none`,padding:0,margin:0,overflow:`visible`,color:`inherit`,background:`transparent`,width:`auto`,height:`auto`};function LU(e){var t=null;return function(){if(!t){var n=[...arguments];t={result:e.apply(this,n)}}return t.result}}var RU=LU(function(){return typeof HTMLElement<`u`&&typeof HTMLElement.prototype.showPopover==`function`});function zU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function BU(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?zU(Object(n),!0).forEach(function(t){PU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zU(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var VU=2,HU=VU/2;function UU(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}function WU(e){return{x:e.x-HU,y:e.y-HU}}function GU(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}function KU(e){return{x:Math.min(e.x,window.innerWidth-VU),y:Math.min(e.y,window.innerHeight-VU)}}function qU(e){var t=e.client,n=KU(GU(WU(UU(t))));return DOMRect.fromRect({x:n.x,y:n.y,width:VU,height:VU})}function JU(e){var t=e.clientRect;return{left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`}}function YU(e){var t=e.client,n=e.clientRect;return t.x>=n.x&&t.x<=n.x+n.width&&t.y>=n.y&&t.y<=n.y+n.height}function XU(e){var t=e.initial,n=document.createElement(`div`);n.setAttribute(OU,`true`),RU()&&n.setAttribute(`popover`,`manual`);var r=qU({client:t});Object.assign(n.style,BU(BU({position:`fixed`},RU()?IU:{zIndex:FU}),{},{backgroundColor:`transparent`,padding:0,margin:0,boxSizing:`border-box`,pointerEvents:`auto`},JU({clientRect:r}))),document.body.appendChild(n),RU()&&n.showPopover();var i=(0,DU.bind)(window,{type:`pointermove`,listener:function(e){r=qU({client:{x:e.clientX,y:e.clientY}}),Object.assign(n.style,JU({clientRect:r}))},options:{capture:!0}});return function(e){var t=e.current;if(i(),YU({client:t,clientRect:r})){n.remove();return}function a(){o(),n.remove()}var o=(0,DU.bindAll)(window,[{type:`pointerdown`,listener:a},{type:`pointermove`,listener:a},{type:`focusin`,listener:a},{type:`focusout`,listener:a},{type:`dragstart`,listener:a},{type:`dragenter`,listener:a},{type:`dragover`,listener:a}],{capture:!0})}}function ZU(){var e=null;function t(){return e=null,(0,DU.bind)(window,{type:`pointermove`,listener:function(t){e={x:t.clientX,y:t.clientY}},options:{capture:!0}})}function n(){var t=null;return function(n){var r=n.eventName,i=n.payload;if(r===`onDragStart`){var a=i.location.initial.input;t=XU({initial:e??{x:a.clientX,y:a.clientY}})}if(r===`onDrop`){var o,s=i.location.current.input;(o=t)==null||o({current:{x:s.clientX,y:s.clientY}}),t=null,e=null}}}return{bindEvents:t,getOnPostDispatch:n}}function QU(e){if(Array.isArray(e))return xU(e)}function $U(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function eW(){throw TypeError(`Invalid attempt to spread non-iterable instance.
69
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tW(e){return QU(e)||$U(e)||SU(e)||eW()}var nW=LU(function(){return navigator.userAgent.includes(`Firefox`)}),rW=LU(function(){var e=navigator.userAgent;return e.includes(`AppleWebKit`)&&!e.includes(`Chrome`)});function iW(e){return`nodeName`in e}function aW(e){return iW(e)&&e.ownerDocument!==document}var oW={isLeavingWindow:Symbol(`leaving`),isEnteringWindow:Symbol(`entering`)};(function(){if(typeof window>`u`||!rW())return;function e(){return{enterCount:0,isOverWindow:!1}}var t=e();function n(){t=e()}(0,DU.bindAll)(window,[{type:`dragstart`,listener:function(){t.enterCount=0,t.isOverWindow=!0}},{type:`drop`,listener:n},{type:`dragend`,listener:n},{type:`dragenter`,listener:function(e){!t.isOverWindow&&t.enterCount===0&&(e[oW.isEnteringWindow]=!0),t.isOverWindow=!0,t.enterCount++}},{type:`dragleave`,listener:function(e){t.enterCount--,t.isOverWindow&&t.enterCount===0&&(e[oW.isLeavingWindow]=!0,t.isOverWindow=!1)}}],{capture:!0})})();function sW(e){var t=e.dragLeave;return rW()?t.hasOwnProperty(oW.isLeavingWindow):!1}function cW(e){var t=e.dragLeave,n=t.type,r=t.relatedTarget;return n===`dragleave`?rW()?sW({dragLeave:t}):r==null?!0:nW()?aW(r):r instanceof HTMLIFrameElement:!1}function lW(e){var t=e.onDragEnd;return[{type:`pointermove`,listener:function(){var e=0;return function(){e<20?e++:t()}}()},{type:`pointerdown`,listener:t}]}function uW(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}var dW=function(e){var t=[],n=null,r=function(){t=[...arguments],!n&&(n=requestAnimationFrame(function(){n=null,e.apply(void 0,t)}))};return r.cancel=function(){n&&=(cancelAnimationFrame(n),null)},r}(function(e){return e()}),fW=function(){var e=null;function t(t){e={frameId:requestAnimationFrame(function(){e=null,t()}),fn:t}}function n(){e&&=(cancelAnimationFrame(e.frameId),e.fn(),null)}return{schedule:t,flush:n}}();function pW(e){var t=e.source,n=e.initial,r=e.dispatchEvent,i={dropTargets:[]};function a(e){r(e),i={dropTargets:e.payload.location.current.dropTargets}}return{start:function(e){var r=e.nativeSetDragImage,o={current:n,previous:i,initial:n};a({eventName:`onGenerateDragPreview`,payload:{source:t,location:o,nativeSetDragImage:r}}),fW.schedule(function(){a({eventName:`onDragStart`,payload:{source:t,location:o}})})},dragUpdate:function(e){var r=e.current;fW.flush(),dW.cancel(),a({eventName:`onDropTargetChange`,payload:{source:t,location:{initial:n,previous:i,current:r}}})},drag:function(e){var r=e.current;dW(function(){fW.flush(),a({eventName:`onDrag`,payload:{source:t,location:{initial:n,previous:i,current:r}}})})},drop:function(e){var r=e.current,o=e.updatedSourcePayload;fW.flush(),dW.cancel(),a({eventName:`onDrop`,payload:{source:o??t,location:{current:r,previous:i,initial:n}}})}}}var mW={isActive:!1};function hW(){return!mW.isActive}function gW(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}function _W(e){var t=e.current,n=e.next;if(t.length!==n.length)return!0;for(var r=0;r<t.length;r++)if(t[r].element!==n[r].element)return!0;return!1}function vW(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=e.dispatchEvent;if(!hW())return;var a=bW({event:t,dragType:n,getDropTargetsOver:r});mW.isActive=!0;var o={current:a};yW({event:t,current:a.dropTargets});var s=pW({source:n.payload,dispatchEvent:i,initial:a});function c(e){var t=_W({current:o.current.dropTargets,next:e.dropTargets});o.current=e,t&&s.dragUpdate({current:o.current})}function l(e){var t=uW(e),i=r({target:kU(e.target)?AU({x:t.clientX,y:t.clientY}):e.target,input:t,source:n.payload,current:o.current.dropTargets});i.length&&(e.preventDefault(),yW({event:e,current:i})),c({dropTargets:i,input:t})}function u(){o.current.dropTargets.length&&c({dropTargets:[],input:o.current.input}),s.drop({current:o.current,updatedSourcePayload:null}),d()}function d(){mW.isActive=!1,f()}var f=(0,DU.bindAll)(window,[{type:`dragover`,listener:function(e){l(e),s.drag({current:o.current})}},{type:`dragenter`,listener:l},{type:`dragleave`,listener:function(e){cW({dragLeave:e})&&(c({input:o.current.input,dropTargets:[]}),n.startedFrom===`external`&&u())}},{type:`drop`,listener:function(e){o.current={dropTargets:o.current.dropTargets,input:uW(e)},o.current.dropTargets.length?(e.preventDefault(),yW({event:e,current:o.current.dropTargets}),s.drop({current:o.current,updatedSourcePayload:n.type===`external`?n.getDropPayload(e):null}),d()):u()}},{type:`dragend`,listener:function(e){o.current={dropTargets:o.current.dropTargets,input:uW(e)},u()}}].concat(tW(lW({onDragEnd:u}))),{capture:!0});s.start({nativeSetDragImage:gW(t)})}function yW(e){var t=e.event,n=e.current[0]?.dropEffect;n!=null&&t.dataTransfer&&(t.dataTransfer.dropEffect=n)}function bW(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=uW(t);return n.startedFrom===`external`?{input:i,dropTargets:[]}:{input:i,dropTargets:r({input:i,source:n.payload,target:t.target,current:[]})}}var xW={canStart:hW,start:vW},SW=new Map;function CW(e){var t=e.typeKey,n=e.mount,r=SW.get(t);if(r)return r.usageCount++,r;var i={typeKey:t,unmount:n(),usageCount:1};return SW.set(t,i),i}function wW(e){var t=CW(e);return function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),SW.delete(e.typeKey))}}function TW(){var e=[...arguments];return function(){e.forEach(function(e){return e()})}}function EW(e,t){var n=t.attribute,r=t.value;return e.setAttribute(n,r),function(){return e.removeAttribute(n)}}function DW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function OW(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?DW(Object(n),!0).forEach(function(t){PU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):DW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function kW(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=AW(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
70
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function AW(e,t){if(e){if(typeof e==`string`)return jW(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?jW(e,t):void 0}}function jW(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function MW(e){return e.slice(0).reverse()}function NW(e){var t=e.typeKey,n=e.defaultDropEffect,r=new WeakMap,i=`data-drop-target-for-${t}`,a=`[${i}]`;function o(e){return r.set(e.element,e),function(){return r.delete(e.element)}}function s(e){return LU(TW(EW(e.element,{attribute:i,value:`true`}),o(e)))}function c(e){var t=e.source,i=e.target,o=e.input,s=e.result,l=s===void 0?[]:s;if(i==null)return l;if(!(i instanceof Element))return i instanceof Node?c({source:t,target:i.parentElement,input:o,result:l}):l;var u=i.closest(a);if(u==null)return l;var d=r.get(u);if(d==null)return l;var f={input:o,source:t,element:d.element};if(d.canDrop&&!d.canDrop(f))return c({source:t,target:d.element.parentElement,input:o,result:l});var p=d.getData?.call(d,f)??{},m=d.getDropEffect?.call(d,f)??n,h={data:p,element:d.element,dropEffect:m,isActiveDueToStickiness:!1};return c({source:t,target:d.element.parentElement,input:o,result:[].concat(tW(l),[h])})}function l(e){var t=e.eventName,n=e.payload,i=kW(n.location.current.dropTargets),a;try{for(i.s();!(a=i.n()).done;){var o,s=a.value,c=r.get(s.element),l=OW(OW({},n),{},{self:s});c==null||(o=c[t])==null||o.call(c,l)}}catch(e){i.e(e)}finally{i.f()}}var u={onGenerateDragPreview:l,onDrag:l,onDragStart:l,onDrop:l,onDropTargetChange:function(e){var t=e.payload,n=new Set(t.location.current.dropTargets.map(function(e){return e.element})),i=new Set,a=kW(t.location.previous.dropTargets),o;try{for(a.s();!(o=a.n()).done;){var s,c=o.value;i.add(c.element);var l=r.get(c.element),u=n.has(c.element),d=OW(OW({},t),{},{self:c});if(l==null||(s=l.onDropTargetChange)==null||s.call(l,d),!u){var f;l==null||(f=l.onDragLeave)==null||f.call(l,d)}}}catch(e){a.e(e)}finally{a.f()}var p=kW(t.location.current.dropTargets),m;try{for(p.s();!(m=p.n()).done;){var h,g,_=m.value;if(!i.has(_.element)){var v=OW(OW({},t),{},{self:_}),y=r.get(_.element);y==null||(h=y.onDropTargetChange)==null||h.call(y,v),y==null||(g=y.onDragEnter)==null||g.call(y,v)}}}catch(e){p.e(e)}finally{p.f()}}};function d(e){u[e.eventName](e)}function f(e){var t=e.source,n=e.target,i=e.input,a=e.current,o=c({source:t,target:n,input:i});if(o.length>=a.length)return o;for(var s=MW(a),l=MW(o),u=[],d=0;d<s.length;d++){var f,p=s[d],m=l[d];if(m!=null)u.push(m);else{var h=u[d-1],g=s[d-1];if(h?.element!==g?.element)break;var _=r.get(p.element);if(!_)break;var v={input:i,source:t,element:_.element};if(_.canDrop&&!_.canDrop(v)||!((f=_.getIsSticky)!=null&&f.call(_,v)))break;u.push(OW(OW({},p),{},{isActiveDueToStickiness:!0}))}}return MW(u)}return{dropTargetForConsumers:s,getIsOver:f,dispatchEvent:d}}function PW(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=FW(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
71
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function FW(e,t){if(e){if(typeof e==`string`)return IW(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?IW(e,t):void 0}}function IW(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function LW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function RW(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?LW(Object(n),!0).forEach(function(t){PU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):LW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function zW(){var e=new Set,t=null;function n(e){t&&(!e.canMonitor||e.canMonitor(t.canMonitorArgs))&&t.active.add(e)}function r(r){var i=RW({},r);e.add(i),n(i);function a(){e.delete(i),t&&t.active.delete(i)}return LU(a)}function i(r){var i=r.eventName,a=r.payload;if(i===`onGenerateDragPreview`){t={canMonitorArgs:{initial:a.location.initial,source:a.source},active:new Set};var o=PW(e),s;try{for(o.s();!(s=o.n()).done;){var c=s.value;n(c)}}catch(e){o.e(e)}finally{o.f()}}if(t){for(var l=Array.from(t.active),u=0,d=l;u<d.length;u++){var f=d[u];if(t.active.has(f)){var p;(p=f[i])==null||p.call(f,a)}}i===`onDrop`&&(t.active.clear(),t=null)}}return{dispatchEvent:i,monitorForConsumers:r}}function BW(e){var t=e.typeKey,n=e.mount,r=e.dispatchEventToSource,i=e.onPostDispatch,a=e.defaultDropEffect,o=zW(),s=NW({typeKey:t,defaultDropEffect:a});function c(e){r?.(e),s.dispatchEvent(e),o.dispatchEvent(e),i?.(e)}function l(e){var t=e.event,n=e.dragType;xW.start({event:t,dragType:n,getDropTargetsOver:s.getIsOver,dispatchEvent:c})}function u(){function e(){return n({canStart:xW.canStart,start:l})}return wW({typeKey:t,mount:e})}return{registerUsage:u,dropTarget:s.dropTargetForConsumers,monitor:o.monitorForConsumers}}var VW=LU(function(){return navigator.userAgent.toLocaleLowerCase().includes(`android`)}),HW=`pdnd:android-fallback`,UW=`text/plain`,WW=`application/vnd.pdnd`,GW=new WeakMap;function KW(e){return GW.set(e.element,e),function(){GW.delete(e.element)}}var qW=ZU(),JW=BW({typeKey:`element`,defaultDropEffect:`move`,mount:function(e){return TW(qW.bindEvents(),(0,DU.bind)(document,{type:`dragstart`,listener:function(t){if(e.canStart(t)&&!t.defaultPrevented&&t.dataTransfer){var n=t.target;if(n instanceof HTMLElement){var r=GW.get(n);if(r){var i=uW(t),a={element:r.element,dragHandle:r.dragHandle??null,input:i};if(r.canDrag&&!r.canDrag(a))t.preventDefault();else{if(r.dragHandle){var o=AU({x:i.clientX,y:i.clientY});if(!r.dragHandle.contains(o)){t.preventDefault();return}}var s=r.getInitialDataForExternal?.call(r,a)??null;if(s)for(var c=0,l=Object.entries(s);c<l.length;c++){var u=wU(l[c],2),d=u[0],f=u[1];t.dataTransfer.setData(d,f??``)}VW()&&!t.dataTransfer.types.includes(`text/plain`)&&!t.dataTransfer.types.includes(`text/uri-list`)&&t.dataTransfer.setData(UW,HW),t.dataTransfer.setData(WW,``);var p={type:`element`,payload:{element:r.element,dragHandle:r.dragHandle??null,data:r.getInitialData?.call(r,a)??{}},startedFrom:`internal`};e.start({event:t,dragType:p})}}}}}}))},dispatchEventToSource:function(e){var t,n,r=e.eventName,i=e.payload;(t=GW.get(i.source.element))==null||(n=t[r])==null||n.call(t,i)},onPostDispatch:qW.getOnPostDispatch()}),YW=JW.dropTarget,XW=JW.monitor;function ZW(e){return LU(TW(JW.registerUsage(),KW(e),EW(e.element,{attribute:`draggable`,value:`true`})))}function QW(e){return e[$W]??null}var $W=Symbol(`closestEdge`);function eG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function tG(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?eG(Object(n),!0).forEach(function(t){PU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eG(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var nG={top:function(e,t){return Math.abs(t.y-e.top)},right:function(e,t){return Math.abs(e.right-t.x)},bottom:function(e,t){return Math.abs(e.bottom-t.y)},left:function(e,t){return Math.abs(t.x-e.left)}};function rG(e,t){var n=t.element,r=t.input,i=t.allowedEdges,a={x:r.clientX,y:r.clientY},o=n.getBoundingClientRect(),s=i.map(function(e){return{edge:e,value:nG[e](o,a)}}).sort(function(e,t){return e.value-t.value})[0]?.edge??null;return tG(tG({},e),{},PU({},$W,s))}function iG(e){var t=e.startIndex,n=e.closestEdgeOfTarget,r=e.indexOfTarget,i=e.axis;if(t===-1||r===-1||t===r)return t;if(n==null)return r;var a=i===`vertical`&&n===`bottom`||i===`horizontal`&&n===`right`;return t<r?a?r:r-1:a?r+1:r}function aG(e,t){return e.list===t&&typeof e.index==`number`}function oG(e,{list:t,index:n,enabled:r}){let[i,a]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let i=e.current;if(!i||!r)return;let o={list:t,index:n};return TW(ZW({element:i,getInitialData:()=>o}),YW({element:i,canDrop:({source:e})=>aG(e.data,t),getData:({input:e})=>rG(o,{element:i,input:e,allowedEdges:[`top`,`bottom`]}),onDrag:({self:e,source:t})=>{let r=QW(e.data),i=t.data.index,o=i===n||r===`top`&&i===n-1||r===`bottom`&&i===n+1;a(o?null:r)},onDragLeave:()=>a(null),onDrop:()=>a(null)}))},[e,t,n,r]),i}function sG(e,t){(0,y.useEffect)(()=>XW({canMonitor:({source:t})=>aG(t.data,e),onDrop:({source:n,location:r})=>{let i=r.current.dropTargets[0];if(!i||!aG(i.data,e))return;let a=n.data.index,o=iG({startIndex:a,indexOfTarget:i.data.index,closestEdgeOfTarget:QW(i.data),axis:`vertical`});o!==a&&t(a,o)}}),[e,t])}function cG({id:e,title:t,children:n}){return(0,G.jsxs)(`div`,{className:`flex h-[29px] items-center justify-between px-3 pt-1.5 text-label text-muted-foreground`,children:[(0,G.jsx)(`h2`,{id:e,children:t}),n]})}var lG=`layers`;function uG({frames:e,calls:t=WE}){let[n,r]=(0,y.useState)(new Set),i=xD(e=>e.page),a=xD(e=>e.frames),o=xD(e=>e.element??null),s=Z(e=>e.canWrite);_G(r);let c=[...e].reverse();sG(lG,(0,y.useCallback)((n,r)=>{let i=[...e].reverse(),a=i[n];a&&t.orderFrame(a.ref,i.length-1-r).catch(ZE(`Couldn't move ${a.name}`))},[e,t]));let l=e=>n.has(e),u=e=>r(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,G.jsxs)(`section`,{"aria-labelledby":`layers-heading`,className:`flex min-h-0 flex-col`,children:[(0,G.jsx)(cG,{id:`layers-heading`,title:`Layers`,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":`Collapse all layers`,title:`Collapse all layers`,onClick:()=>r(new Set),className:`grid size-5 place-items-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:(0,G.jsx)(tn,{"aria-hidden":!0,className:`size-[15px]`})})}),e.length===0?(0,G.jsx)(`p`,{className:`px-3.5 py-1 text-faint`,children:`No frames on this page`}):(0,G.jsx)(`ul`,{className:`flex min-h-0 flex-col overflow-y-auto pb-1`,children:c.map((e,n)=>{let r=l(e.ref),c=o?.frame===e.ref,d=!c&&i===gG(e)&&a.includes(e.ref);return(0,G.jsx)(mG,{frame:e,index:n,canWrite:s,calls:t,tint:d?`bg-primary/26`:c?`bg-primary/7`:void 0,chevron:(0,G.jsx)(`button`,{type:`button`,"aria-label":`${r?`Hide`:`Show`} the elements of ${e.name}`,"aria-expanded":r,onClick:()=>u(e.ref),className:`grid w-2.5 shrink-0 place-items-center text-faint outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:r?(0,G.jsx)(dt,{"aria-hidden":!0,className:`size-2.5`}):(0,G.jsx)(pt,{"aria-hidden":!0,className:`size-2.5`})}),children:r?(0,G.jsx)(gU,{frame:e,page:gG(e),selected:c?o?.index??null:null,frameSelected:d,isOpen:t=>l(hG(e.ref,t)),toggle:t=>u(hG(e.ref,t))}):null},e.ref)})})]})}var dG=`grid size-5 shrink-0 place-items-center rounded-[5px] outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none`,fG=`opacity-0 group-hover:opacity-100 group-focus-within:opacity-100`,pG={hidden:[`show`,`hide`],locked:[`unlock`,`lock`]};function mG({frame:e,index:t,canWrite:n,calls:r,tint:i,chevron:a,children:o}){let s=(0,y.useRef)(null),c=WF(`layers`)===e.ref,l=Z(t=>t.claims[e.ref]),u=jN(t=>e.ref in t.unseen),d=oG(s,{list:lG,index:t,enabled:n&&!c}),f=t=>{e.hidden||iD.getState().mode!==`edit`||(t.shiftKey?lD(bD,gG(e),e.ref):sD(bD,gG(e),[e.ref]))},p=(t,n)=>r.flagFrames([e.ref],t,n).catch(ZE(`Couldn't ${pG[t][+!!n]} ${e.name}`)),m=(0,G.jsx)(Xn,{"aria-hidden":!0,className:X(`size-[13px] shrink-0`,e.hidden?`text-faint`:`text-muted-foreground`)});return(0,G.jsxs)(`li`,{ref:s,"aria-label":e.hidden?`${e.name}, hidden`:e.name,className:`relative mx-1.5`,children:[(0,G.jsx)(pU,{edge:d}),(0,G.jsxs)(`div`,{className:`flex flex-col overflow-hidden rounded-md`,children:[(0,G.jsx)(dU,{frame:e,page:gG(e),trigger:(0,G.jsxs)(`div`,{className:X(`group flex h-[26px] items-center gap-1.5 pr-1 pl-2 text-foreground`,e.hidden&&`text-faint`,i??`hover:bg-accent`),children:[a,c?(0,G.jsxs)(G.Fragment,{children:[m,(0,G.jsx)(lH,{name:e.name,label:`Rename frame ${e.name}`,onCommit:t=>{KF(),qF(e,t,r)},onCancel:KF})]}):(0,G.jsxs)(`button`,{type:`button`,"aria-label":`Select ${e.name}`,onClick:f,onDoubleClick:()=>{n&&GF(e.ref,`layers`)},onKeyDown:t=>{t.key===`F2`&&n&&(t.preventDefault(),GF(e.ref,`layers`))},className:`flex h-full min-w-0 flex-1 items-center gap-1.5 rounded-[5px] text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-inset`,children:[m,(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})]}),l?(0,G.jsx)(`span`,{role:`img`,"aria-label":`${l.tag} is editing`,className:`ml-auto size-[7px] shrink-0 rounded-full bg-claim shadow-[0_0_0_3px_color-mix(in_srgb,var(--claim)_25%,transparent)]`}):u?(0,G.jsx)($P,{}):null,(0,G.jsx)(`button`,{type:`button`,"aria-label":`${e.hidden?`Show`:`Hide`} ${e.name}`,"aria-pressed":e.hidden,disabled:!n,onClick:()=>void p(`hidden`,!e.hidden),className:X(dG,e.hidden?`text-faint`:X(`text-muted-foreground`,fG)),children:e.hidden?(0,G.jsx)(jt,{"aria-hidden":!0,className:`size-[13px]`}):(0,G.jsx)(Nt,{"aria-hidden":!0,className:`size-[13px]`})}),(0,G.jsx)(`button`,{type:`button`,"aria-label":`${e.locked?`Unlock`:`Lock`} ${e.name}`,"aria-pressed":e.locked,disabled:!n,onClick:()=>void p(`locked`,!e.locked),className:X(dG,`text-muted-foreground`,!e.locked&&fG),children:e.locked?(0,G.jsx)(un,{"aria-hidden":!0,className:`size-[13px]`}):(0,G.jsx)(cn,{"aria-hidden":!0,className:`size-[13px]`})})]})}),o]})]})}function hG(e,t){return`${e}#${t}`}function gG(e){return`${e.project}/${e.page}`}function _G(e){(0,y.useEffect)(()=>{let t=null,n=()=>{let n=t;if(!n)return;let r=NP(n.frame),i=[n.frame];if(r){t=null;for(let e=RP(r.elements,n.index);typeof e==`number`;e=RP(r.elements,e))i.push(hG(n.frame,e))}e(e=>i.every(t=>e.has(t))?e:new Set([...e,...i]))},r=bD.subscribe((e,r)=>{e.element&&e.element!==r.element&&(t=e.element,n())}),i=MP.store.subscribe(n);return()=>{i(),r()}},[e])}function vG({count:e,className:t}){return e===0?null:(0,G.jsx)(`span`,{role:`img`,"aria-label":`${e} unseen ${e===1?`change`:`changes`}`,"data-unseen-count":!0,className:X(`shrink-0 text-[11px] font-semibold text-claim`,t),children:e})}var yG=[`page.rename`,`page.duplicate`,`page.new`,`page.delete`];function bG({onOpen:e,trigger:t}){let[n,r,i,a]=Ce(yG),o=(0,y.useRef)(null),s=lU(o);return(0,G.jsxs)(ER,{onOpenChange:t=>{t&&e()},onOpenChangeComplete:s.onOpenChangeComplete,children:[(0,G.jsx)(DR,{render:t,onKeyDown:s.onKeyDown}),(0,G.jsxs)(OR,{ref:o,children:[(0,G.jsxs)(kR,{children:[(0,G.jsx)(IR,{children:`Page`}),(0,G.jsx)(PR,{action:n,children:`Rename`}),(0,G.jsx)(PR,{action:r,children:`Duplicate`}),(0,G.jsx)(PR,{action:i,children:`New page below`})]}),(0,G.jsx)(MR,{}),(0,G.jsx)(FR,{action:a})]})]})}var xG=`pages`,SG=`grid size-5 place-items-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:bg-transparent aria-pressed:bg-accent aria-pressed:text-foreground`;function CG({pages:e,current:t,calls:n=WE}){let[,r]=Rr(),i={current:t,navigate:r,calls:n},[a]=Ce([`page.new`]),o=a?Se(a):!1,s=Z(e=>e.canWrite),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(``),f=u.trim().toLowerCase(),p=f?e.filter(e=>e.name.toLowerCase().includes(f)):e;sG(xG,(0,y.useCallback)((t,r)=>{let i=e[t];i&&n.movePage(i.ref,r).catch(ZE(`Couldn't move ${i.name}`))},[e,n]));let m=()=>{l(!1),d(``)};return(0,G.jsxs)(`nav`,{"aria-labelledby":`pages-heading`,className:`flex h-full min-h-0 flex-col`,children:[(0,G.jsx)(cG,{id:`pages-heading`,title:`Pages`,children:(0,G.jsxs)(`span`,{className:`flex gap-0.5`,children:[(0,G.jsx)(fB,{label:`Search pages`,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":`Search pages`,"aria-pressed":c,onClick:()=>c?m():l(!0),className:SG,children:(0,G.jsx)(Kn,{"aria-hidden":!0,className:`size-[13px]`})})}),(0,G.jsx)(fB,{label:a?.label??`Add page`,keys:a?.keys,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":a?.label??`Add page`,"aria-disabled":!o||void 0,onClick:()=>{a&&o&&a.run()},className:SG,children:(0,G.jsx)(Pn,{"aria-hidden":!0,className:`size-[13px]`})})})]})}),c?(0,G.jsxs)(`div`,{className:`mx-2 mb-1.5 flex h-[26px] shrink-0 items-center gap-1.5 rounded-md bg-muted px-2 ring-[1.5px] ring-primary`,children:[(0,G.jsx)(Kn,{"aria-hidden":!0,className:`size-[13px] shrink-0 text-muted-foreground`}),(0,G.jsx)(`input`,{autoFocus:!0,"aria-label":`Search pages`,value:u,spellCheck:!1,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),m())},className:`min-w-0 flex-1 bg-transparent text-foreground outline-none`}),(0,G.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground`,children:`Esc`})]}):null,p.length===0&&f?(0,G.jsxs)(`p`,{className:`px-3.5 py-1 text-faint`,children:[`No page names match `,u.trim()]}):(0,G.jsx)(`ul`,{className:`flex min-h-0 flex-col -mt-1 overflow-y-auto pt-1 pb-0.5`,children:p.map(t=>(0,G.jsx)(TG,{page:t,pages:e,context:i,needle:f,canWrite:s},t.ref))})]})}var wG=`mx-1.5 flex h-[26px] items-center gap-1.5 rounded-md pr-2 pl-2 text-foreground`;function TG({page:e,pages:t,context:n,needle:r,canWrite:i}){let{current:a}=n,o=(0,y.useRef)(null),s=JE()===e.ref,c=jN(t=>wN(t.unseen,e.ref)),l=oG(o,{list:xG,index:e.index,enabled:i&&!r&&!s}),u=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`w-2.5 shrink-0`}),(0,G.jsx)(zt,{"aria-hidden":!0,className:`size-[13px] shrink-0 text-muted-foreground`})]});return(0,G.jsxs)(`li`,{ref:o,className:`relative`,children:[(0,G.jsx)(pU,{edge:l}),s?(0,G.jsxs)(`div`,{className:X(wG,e.name===a&&`bg-accent`),children:[u,(0,G.jsx)(lH,{name:e.name,label:`Rename page ${e.name}`,onCommit:t=>{XE(),$E(e,t,n)},onCancel:XE})]}):(0,G.jsx)(bG,{onOpen:()=>{e.name!==a&&n.navigate(z(e.project,e.name))},trigger:(0,G.jsxs)(Gr,{href:z(e.project,e.name),"aria-current":e.name===a?`page`:void 0,draggable:!1,onDoubleClick:()=>{i&&YE(e.ref)},onKeyDown:r=>{if(i){if(r.key===`F2`)YE(e.ref);else if(r.key===`Delete`||r.key===`Backspace`)eD(e,t,n);else return;r.preventDefault(),r.stopPropagation()}},className:X(wG,`outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset aria-[current=page]:bg-accent`),children:[u,(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:(0,G.jsx)(EG,{name:e.name,needle:r})}),(0,G.jsx)(vG,{count:c}),e.layoutError?(0,G.jsx)(fr,{role:`img`,"aria-label":`Layout does not read`,className:`size-3.5 shrink-0 text-note`,children:(0,G.jsx)(`title`,{children:`Layout does not read`})}):null]})})]})}function EG({name:e,needle:t}){let n=t?e.toLowerCase().indexOf(t):-1;return n<0?e:(0,G.jsxs)(G.Fragment,{children:[e.slice(0,n),(0,G.jsx)(`mark`,{className:`rounded-[2px] bg-primary/30 text-inherit`,children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}var DG=`frameboard.board.pages`,OG=26,kG=64,AG=237,jG=`h-6 rounded-[5px] border-0 text-xs font-medium text-muted-foreground data-active:bg-card data-active:text-foreground data-active:shadow-none data-active:ring-1 data-active:ring-border dark:data-active:bg-card`;function MG({project:e,page:t,theme:n,assets:r,storage:i,calls:a}){let[o]=Ce([`view.hideUi`]),s=qB(e=>e.open),c=Do({id:DG,onlySaveAfterUserInteractions:!0,storage:i}),l=Math.min(Math.max(29+e.pages.length*OG+4,kG),AG),u=e.pages.find(e=>e.name===t)?.frames??[];return(0,G.jsxs)(`aside`,{"aria-label":`Pages and layers`,className:`flex h-full min-w-0 flex-col bg-sidebar text-sidebar-foreground`,children:[(0,G.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-1.5 border-b border-sidebar-border px-2`,children:[(0,G.jsx)(fB,{label:`Home`,side:`bottom`,children:(0,G.jsx)(Gr,{href:`/`,"aria-label":`Home`,className:NG,children:(0,G.jsx)(qt,{"aria-hidden":!0,className:`size-[15px]`})})}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-panel`,title:e.name,children:e.name}),(0,G.jsx)(fB,{label:`Hide UI`,keys:o?.keys,side:`bottom`,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":`Hide UI`,onClick:()=>o?.run(),className:NG,children:(0,G.jsx)(En,{"aria-hidden":!0,className:`size-[15px]`})})})]}),s?(0,G.jsx)(rU,{project:e.name,page:t}):(0,G.jsxs)(VH,{defaultValue:`design`,className:`min-h-0 flex-1 gap-0`,children:[(0,G.jsxs)(UH,{className:`m-2 h-7 w-auto shrink-0 rounded-[7px] p-0.5`,children:[(0,G.jsx)(WH,{value:`design`,className:jG,children:`Design`}),(0,G.jsx)(WH,{value:`theme`,disabled:!n,className:jG,children:`Theme`}),(0,G.jsx)(WH,{value:`assets`,disabled:!r,className:jG,children:`Assets`})]}),(0,G.jsx)(GH,{value:`design`,className:`flex min-h-0 flex-col text-xs`,children:(0,G.jsxs)(al,{id:DG,orientation:`vertical`,defaultLayout:c.defaultLayout,onLayoutChanged:c.onLayoutChanged,children:[(0,G.jsx)(ol,{id:`pages`,defaultSize:l,minSize:kG,children:(0,G.jsx)(CG,{pages:e.pages,current:t,calls:a})}),(0,G.jsx)(sl,{"aria-label":`Resize the pages list`,className:`group cursor-row-resize aria-[orientation=horizontal]:h-[9px] border-t border-sidebar-border bg-transparent after:hidden focus-visible:ring-0 data-[separator=active]:border-t-2 data-[separator=active]:border-primary data-[separator=focus]:border-t-2 data-[separator=focus]:border-primary`,children:(0,G.jsx)(`span`,{"aria-hidden":!0,className:`h-[3px] w-7 rounded-[2px] bg-faint group-data-[separator=active]:bg-primary group-data-[separator=focus]:bg-primary`})}),(0,G.jsx)(ol,{id:`layers`,minSize:kG,children:(0,G.jsx)(uG,{frames:u,calls:a})})]})}),(0,G.jsx)(GH,{value:`theme`,className:`min-h-0 text-xs`,children:n}),(0,G.jsx)(GH,{value:`assets`,className:`min-h-0 text-xs`,children:r})]})]})}var NG=`grid size-[26px] shrink-0 place-items-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,PG=[`color`,`radius`,`font`,`other`],FG=MT({name:eT(),group:zT(PG),light:eT().nullable(),dark:eT().nullable(),sheet:eT()});MT({sheets:AT(MT({path:eT(),kind:zT([`board`,`project`]),error:eT().nullable()})),tokens:AT(FG)});var IG={color:`Color`,radius:`Radius`,font:`Font`,other:`Other`},LG=`font-mono text-label font-normal text-foreground`;function RG({project:e,load:t=aV}){let n=iV(e,t);return n===void 0?null:n===null?(0,G.jsx)(`p`,{className:`m-3 text-muted-foreground`,children:`The tokens did not load. Reload the board to try again.`}):n.sheets.length===0?(0,G.jsx)(zG,{}):(0,G.jsxs)(`div`,{className:`flex flex-col pb-2`,children:[(0,G.jsxs)(`p`,{className:`mx-3 mt-1 mb-2 rounded-lg bg-muted px-2.5 py-2 leading-[1.45] text-muted-foreground`,children:[`From`,` `,n.sheets.map((e,t)=>(0,G.jsxs)(y.Fragment,{children:[t>0?` and `:null,(0,G.jsx)(`code`,{className:LG,children:e.path})]},e.path)),`, read-only. Edit the file or ask the agent.`]}),n.sheets.filter(e=>e.error!==null).map(e=>(0,G.jsxs)(`p`,{role:`alert`,className:`mx-3 mb-2 leading-[1.45] text-destructive`,children:[(0,G.jsx)(`code`,{className:LG,children:e.path}),` does not parse, so its tokens are missing here: `,e.error,`. Fix the file or ask the agent.`]},e.path)),n.tokens.length===0?(0,G.jsx)(`p`,{className:`mx-3 text-muted-foreground`,children:`These sheets set no tokens under :root, [data-theme], or .dark.`}):null,PG.map(e=>{let t=n.tokens.filter(t=>t.group===e);return t.length===0?null:(0,G.jsxs)(`section`,{"aria-labelledby":`tokens-${e}`,children:[(0,G.jsx)(`h3`,{id:`tokens-${e}`,className:`px-3 pt-2.5 pb-1 text-label text-muted-foreground`,children:IG[e]}),e===`color`?(0,G.jsx)(BG,{}):null,(0,G.jsx)(`ul`,{children:t.map(t=>e===`color`?(0,G.jsx)(VG,{row:t},t.name):(0,G.jsx)(HG,{row:t},t.name))})]},e)})]})}function zG(){return(0,G.jsxs)(`div`,{className:`m-3 rounded-[10px] border border-dashed border-border p-4 leading-normal text-muted-foreground`,children:[(0,G.jsx)(`p`,{className:`mb-1 font-semibold text-foreground`,children:`No tokens yet`}),`Frames render unstyled until a token sheet exists. Add one at`,` `,(0,G.jsx)(`code`,{className:LG,children:`tokens.css`}),` in this project, or in the board folder for every project.`]})}function BG(){return(0,G.jsxs)(`div`,{"aria-hidden":!0,className:`grid grid-cols-[1fr_18px_18px] gap-1.5 px-3 py-1 text-center text-[10px] text-faint`,children:[(0,G.jsx)(`span`,{}),(0,G.jsx)(`span`,{children:`L`}),(0,G.jsx)(`span`,{children:`D`})]})}function VG({row:e}){return(0,G.jsxs)(`li`,{className:`mx-1.5 grid h-7 grid-cols-[1fr_18px_18px] items-center gap-1.5 rounded-md px-1.5`,children:[(0,G.jsx)(UG,{name:e.name}),(0,G.jsx)(WG,{theme:`Light`,value:e.light}),(0,G.jsx)(WG,{theme:`Dark`,value:e.dark})]})}function HG({row:e}){let t=GG(e);return(0,G.jsxs)(`li`,{className:`mx-1.5 grid h-7 grid-cols-[1fr_auto] items-center gap-1.5 rounded-md px-1.5`,children:[(0,G.jsx)(UG,{name:e.name}),(0,G.jsx)(`span`,{className:`max-w-32 truncate text-muted-foreground`,title:t,children:t})]})}function UG({name:e}){return(0,G.jsxs)(`span`,{className:`truncate`,title:e,children:[(0,G.jsx)(`span`,{className:`text-faint`,children:`--`}),e.replace(/^--/,``)]})}function WG({theme:e,value:t}){return t===null?(0,G.jsx)(`span`,{role:`img`,"aria-label":`${e}: not set`,title:`Not set in ${e.toLowerCase()}`,className:`size-4 rounded-[4px] border border-dashed border-faint`}):(0,G.jsx)(`span`,{role:`img`,"aria-label":`${e}: ${t}`,title:t,className:`size-4 rounded-[4px] shadow-[inset_0_0_0_1px_rgba(127,127,127,.35)]`,style:{background:t}})}function GG(e){let t=e.light??e.dark??``;return e.group===`font`?t.split(`,`)[0]?.trim().replace(/^["']|["']$/g,``)??t:t}var KG={defaultSize:240,minSize:200,maxSize:400},qG=[],JG=`frameboard.board.panels`;function YG({project:e,page:t}){let n=Z(t=>t.board?.projects.find(t=>t.name===e)),r=Z(e=>e.reloads),i=Z(e=>e.findings),a=Z(e=>e.claims),o=Z(e=>e.focus),s=(0,y.useCallback)(()=>yl.setState({focus:null}),[]),c=aD(e=>e.hideUi),l=aD(e=>e.mode===`play`),u=Do({id:JG,panelIds:c?[`canvas`]:[`left`,`canvas`,`right`],onlySaveAfterUserInteractions:!0,storage:ZG}),d=n?.pages.find(e=>e.name===t);if(RD(),tD(e,t),YF(d?.ref??``,d?.frames??qG),iI(),Az(),XB(),!n)return(0,G.jsx)(XG,{message:`No project ${e} on this board.`});let f=n.pages[0];return t===void 0&&f?(0,G.jsx)(Jr,{to:z(e,f.name),replace:!0}):(0,G.jsxs)(al,{id:`board`,className:`text-body`,defaultLayout:u.defaultLayout,onLayoutChanged:u.onLayoutChanged,children:[c?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ol,{id:`left`,...KG,groupResizeBehavior:`preserve-pixel-size`,children:(0,G.jsx)(MG,{project:n,page:t??``,theme:(0,G.jsx)(RG,{project:n.name}),assets:(0,G.jsx)(Fl,{project:n.name}),storage:ZG})}),(0,G.jsx)(sl,{"aria-label":`Resize the left panel`})]}),(0,G.jsx)(ol,{id:`canvas`,children:(0,G.jsxs)(`main`,{className:`relative size-full min-w-0`,children:[d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Sz,{page:d,reloads:r,findings:i,claims:a,focus:o,onFocused:s},d.ref),(0,G.jsx)(BB,{}),(0,G.jsx)(Iz,{})]}):(0,G.jsx)(XG,{message:f?`No page ${t} in ${e}.`:`${e} has no pages yet. An agent adds one with frameboard page add <name>.`}),l?(0,G.jsx)(IB,{}):null,c?(0,G.jsx)(FB,{project:n.name}):null]})}),c?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(sl,{"aria-label":`Resize the inspector`}),(0,G.jsx)(ol,{id:`right`,...KG,groupResizeBehavior:`preserve-pixel-size`,children:(0,G.jsx)(hH,{})})]})]})}function XG({message:e}){return(0,G.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,G.jsx)(`p`,{className:`text-body text-muted-foreground`,children:e}),(0,G.jsx)(Gr,{href:`/`,className:rl({variant:`outline`}),children:`Go home`})]})}var ZG={getItem:e=>{try{return localStorage.getItem(e)}catch{return null}},setItem:(e,t)=>{try{localStorage.setItem(e,t)}catch{}}},QG=[`home.layoutGrid`,`home.layoutList`,`project.new`,`theme.toggle`];function $G({hasProjects:e}){let[t,n,r,i]=Ce(QG);return(0,G.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-3 border-b border-border bg-card px-4 sm:px-6`,children:[(0,G.jsxs)(`span`,{className:`flex flex-1 items-center gap-2 text-sm font-semibold`,children:[(0,G.jsx)(rK,{}),`Frameboard`]}),e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{role:`group`,"aria-label":`Layout`,className:`flex rounded-lg bg-muted p-0.5`,children:[(0,G.jsx)(tK,{action:t,label:`Grid`,children:(0,G.jsx)(Zt,{"aria-hidden":!0,className:`size-3.5`})}),(0,G.jsx)(tK,{action:n,label:`List`,children:(0,G.jsx)(rn,{"aria-hidden":!0,className:`size-3.5`})})]}),(0,G.jsx)(eK,{action:r,compact:!0})]}):null,(0,G.jsxs)(`button`,{type:`button`,"aria-label":i?.label??`Theme`,title:i?.label??`Theme`,...nK(i),className:`grid size-[26px] place-items-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:bg-transparent`,children:[(0,G.jsx)(er,{"aria-hidden":!0,className:`size-[15px] dark:hidden`}),(0,G.jsx)(vn,{"aria-hidden":!0,className:`hidden size-[15px] dark:block`})]})]})}function eK({action:e,className:t,compact:n=!1}){return(0,G.jsxs)(`button`,{type:`button`,"aria-label":`New project`,...nK(e),className:X(`flex h-[30px] items-center gap-1.5 rounded-lg bg-primary px-3 font-medium text-primary-foreground outline-none hover:bg-primary/90 focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:bg-primary`,t),children:[(0,G.jsx)(Pn,{"aria-hidden":!0,className:`size-3.5`}),(0,G.jsx)(`span`,{className:X(`whitespace-nowrap`,n&&`hidden sm:inline`),children:`New project`})]})}function tK({action:e,label:t,children:n}){let r=e?.checked?.()??!1;return(0,G.jsx)(`button`,{type:`button`,"aria-label":t,title:t,"aria-pressed":r,...nK(e),className:X(`grid h-[26px] w-7 place-items-center rounded-md text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,r&&`bg-card text-foreground ring-1 ring-border`),children:n})}function nK(e){let t=e?Se(e):!1;return{"aria-disabled":!t||void 0,onClick:()=>{e&&t&&e.run()}}}function rK(){return(0,G.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 64 64`,className:`size-5`,children:[(0,G.jsx)(`rect`,{x:`4`,y:`12`,width:`48`,height:`48`,rx:`12`,className:`fill-primary`}),(0,G.jsx)(`rect`,{x:`34`,y:`4`,width:`26`,height:`26`,rx:`7`,strokeWidth:`4`,className:`fill-foreground stroke-card`})]})}function iK(){let[e]=Ce([`project.new`]);return(0,G.jsx)(`div`,{className:`relative flex-1`,children:(0,G.jsxs)(`div`,{className:`absolute top-1/2 left-1/2 w-105 max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-[55%] text-center leading-[1.6] text-muted-foreground`,children:[(0,G.jsx)(`div`,{"aria-hidden":!0,className:`mx-auto mb-3.5 h-12 w-16 rounded-lg border-[1.5px] border-dashed border-faint`}),(0,G.jsx)(`h1`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`No projects yet`}),(0,G.jsx)(`p`,{children:`A project holds the pages and frames for one thing you are designing.`}),(0,G.jsx)(eK,{action:e,className:`mx-auto mt-3.5 mb-2.5`}),(0,G.jsxs)(`p`,{children:[`or from a terminal`,` `,(0,G.jsx)(`code`,{className:`rounded-[5px] bg-muted px-1.5 py-0.5 font-mono text-label font-normal text-foreground`,children:`frameboard project add <name>`})]})]})})}var aK=`frameboard.home.layout`;function oK(){let[e,t]=(0,y.useState)(sK),n=(0,y.useRef)(e);return(0,y.useEffect)(()=>{let e=e=>{n.current=e,t(e),cK(e),xe()};return be([{id:`home.layoutGrid`,label:`Grid`,group:`home`,command:{label:`Show projects as a grid`,icon:Zt},run:()=>e(`grid`),checked:()=>n.current===`grid`},{id:`home.layoutList`,label:`List`,group:`home`,command:{label:`Show projects as a list`,icon:rn},run:()=>e(`list`),checked:()=>n.current===`list`}])},[]),e}function sK(){try{return localStorage.getItem(aK)===`list`?`list`:`grid`}catch{return`grid`}}function cK(e){try{localStorage.setItem(aK,e)}catch{}}var lK=ue()(()=>({focused:null,renaming:null}));function uK(e){return fe(lK,t=>t.renaming?.project===e?t.renaming:null)}function dK(e){lK.getState().focused!==e&&(lK.setState({focused:e}),xe())}function fK(e){lK.setState({renaming:{project:e,draft:e,refusal:null,attempt:0}})}function pK(){lK.setState({renaming:null})}function mK({name:e,pages:t}){let n=t[0];return n?z(e,n.name):`/p/${encodeURIComponent(e)}`}async function hK(e,t,n=WE){lK.setState(({renaming:e})=>({renaming:e&&{...e,draft:t}}));try{await n.renameProject(e,t)}catch(t){if(t instanceof jl&&t.code===`invalid-name`){lK.setState(({renaming:e})=>({renaming:e&&{...e,refusal:t.message,attempt:e.attempt+1}}));return}pK(),ZE(`Couldn't rename ${e}`)(t);return}pK(),dK(t)}function gK(e=WE){let[,t]=Rr();(0,y.useEffect)(()=>{let n=()=>yl.getState().canWrite,r=()=>{let e=lK.getState().focused;return yl.getState().board?.projects.find(t=>t.name===e)},i=()=>n()&&r()!==void 0,a=be([{id:`project.new`,label:`New project`,group:`project`,command:{label:`New project`,icon:Vt},enabled:n,run:()=>{e.addProject().then(e=>{dK(e.name),fK(e.name)},ZE(`Couldn't add a project`))}},{id:`project.open`,label:`Open`,group:`project`,enabled:()=>r()!==void 0,run:()=>{let e=r();e&&t(mK(e))}},{id:`project.rename`,label:`Rename`,group:`project`,enabled:i,run:()=>{let e=r();e&&fK(e.name)}},{id:`project.duplicate`,label:`Duplicate`,group:`project`,enabled:i,run:()=>{let t=r();t&&e.duplicateProject(t.name).then(e=>dK(e.name),ZE(`Couldn't duplicate ${t.name}`))}},{id:`project.delete`,label:`Delete`,group:`project`,enabled:i,run:()=>{let t=r();t&&e.deleteProject(t.name).catch(ZE(`Couldn't delete ${t.name}`))}}]),o=yl.subscribe((e,t)=>{(e.canWrite!==t.canWrite||e.board!==t.board)&&xe()});return()=>{o(),a(),lK.setState({focused:null,renaming:null})}},[e,t])}var _K=[`project.open`,`project.rename`,`project.duplicate`,`project.delete`];function vK({project:e,trigger:t}){let[n,r,i,a]=Ce(_K),o=(0,y.useRef)(null),s=lU(o);return(0,G.jsxs)(ER,{onOpenChange:t=>{t&&dK(e)},onOpenChangeComplete:s.onOpenChangeComplete,children:[(0,G.jsx)(DR,{render:t,onKeyDown:s.onKeyDown}),(0,G.jsxs)(OR,{ref:o,children:[(0,G.jsxs)(kR,{children:[(0,G.jsx)(AR,{children:`Project`}),(0,G.jsx)(yK,{action:n,keyHint:`↵`,keyName:`Enter`,children:`Open`}),(0,G.jsx)(yK,{action:r,children:`Rename`}),(0,G.jsx)(yK,{action:i,children:`Duplicate`})]}),(0,G.jsx)(MR,{}),(0,G.jsx)(yK,{action:a,keyHint:`⌫`,keyName:`Delete`,variant:`destructive`,children:`Delete`})]})]})}function yK({action:e,children:t,keyHint:n,keyName:r,variant:i}){return(0,G.jsxs)(jR,{variant:i,disabled:!e||!Se(e),"aria-keyshortcuts":r,onClick:()=>e?.run(),children:[t,n?(0,G.jsx)(NR,{"aria-hidden":!0,children:n}):null]})}function bK({project:e,captures:t,className:n}){let r=(e.pages[0]?.frames??[]).filter(e=>!e.hidden);if(r.length===0)return null;let i=r.map(e=>e.box),a=Math.min(...i.map(e=>e.x)),o=Math.min(...i.map(e=>e.y)),s=Math.max(...i.map(e=>e.x+e.width)),c=Math.max(...i.map(e=>e.y+e.height));return(0,G.jsx)(`svg`,{"aria-hidden":!0,"data-skeleton":!0,viewBox:`${a} ${o} ${s-a} ${c-o}`,preserveAspectRatio:`xMidYMin meet`,className:n,children:r.map(({ref:e,box:n})=>{let r=t?.stamps[e];return(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`rect`,{x:n.x,y:n.y,width:n.width,height:n.height,className:`fill-white stroke-black/6`,strokeWidth:1,vectorEffect:`non-scaling-stroke`}),t&&r?(0,G.jsx)(`image`,{href:xK(e,t.theme,r),x:n.x,y:n.y,width:n.width,height:n.height,preserveAspectRatio:`none`}):null]},e)})})}function xK(e,t,n){return`/api/thumbnails/png?${new URLSearchParams({ref:e,theme:t,v:n})}`}function SK({projects:e,layout:t,now:n,calls:r}){let i=jN(e=>e.unseen),a=tv(),o={theme:a,stamps:Z(e=>e.thumbnails[a])};return(0,G.jsxs)(`main`,{className:`px-4 py-8 sm:px-12`,children:[(0,G.jsx)(`h1`,{className:`mb-5 text-title`,children:`Projects`}),t===`grid`?(0,G.jsx)(`ul`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-5`,children:e.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(CK,{project:e,className:`block overflow-hidden rounded-xl border border-border bg-card text-card-foreground outline-none hover:ring-2 hover:ring-primary focus-visible:ring-2 focus-visible:ring-primary data-popup-open:ring-2 data-popup-open:ring-primary`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`m-1.5 block h-[150px] overflow-hidden rounded-lg bg-background p-3.5`,children:(0,G.jsx)(bK,{project:e,captures:o,className:`size-full`})}),(0,G.jsxs)(`span`,{className:`flex flex-col px-3 pt-1.5 pb-3`,children:[(0,G.jsx)(TK,{project:e,calls:r,type:`text-panel`,unseen:wN(i,e.name)}),(0,G.jsx)(DK,{project:e,now:n,prefix:`Edited `})]})]})},e.name))}):(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card text-card-foreground`,children:[(0,G.jsxs)(`div`,{"aria-hidden":!0,className:`grid h-9 grid-cols-[48px_1fr] sm:grid-cols-[48px_1fr_160px_160px] items-center border-b border-border px-4 text-label text-muted-foreground`,children:[(0,G.jsx)(`span`,{}),(0,G.jsx)(`span`,{children:`Name`}),(0,G.jsx)(`span`,{className:`hidden sm:block`,children:`Edited`}),(0,G.jsx)(`span`,{className:`hidden sm:block`,children:`Created`})]}),(0,G.jsx)(`ul`,{children:e.map(e=>(0,G.jsx)(`li`,{className:`not-last:border-b`,children:(0,G.jsxs)(CK,{project:e,className:`grid h-12 grid-cols-[48px_1fr] sm:grid-cols-[48px_1fr_160px_160px] items-center px-4 outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset data-popup-open:ring-2 data-popup-open:ring-primary data-popup-open:ring-inset`,children:[(0,G.jsx)(EK,{project:e}),(0,G.jsx)(TK,{project:e,calls:r,type:`font-medium`,unseen:wN(i,e.name),className:`pr-4`}),(0,G.jsx)(`span`,{className:`hidden truncate sm:block`,children:(0,G.jsx)(DK,{project:e,now:n,prefix:``})}),(0,G.jsx)(`span`,{className:`hidden sm:block`,children:(0,G.jsx)(OK,{project:e})})]})},e.name))})]})]})}function CK({project:e,className:t,children:n}){return uK(e.name)===null?(0,G.jsx)(vK,{project:e.name,trigger:(0,G.jsx)(Gr,{href:mK(e),onFocus:()=>dK(e.name),onKeyDown:t=>{let n=wK[t.key];if(!n)return;dK(e.name);let r=we(n);r&&Se(r)&&r.run(),t.preventDefault()},className:t,children:n})}):(0,G.jsx)(`div`,{className:t,children:n})}var wK={F2:`project.rename`,Delete:`project.delete`,Backspace:`project.delete`};function TK({project:e,calls:t,type:n,unseen:r,className:i}){let a=uK(e.name);return a?(0,G.jsxs)(`span`,{className:X(`flex min-w-0 flex-col`,n),children:[(0,G.jsx)(`span`,{className:`flex h-lh items-center pl-1.5`,children:(0,G.jsx)(lH,{name:a.draft,label:`Rename project ${e.name}`,onCommit:n=>void hK(e.name,n,t),onCancel:pK},a.attempt)}),a.refusal?(0,G.jsx)(`span`,{role:`alert`,className:`mt-1 text-label font-normal text-destructive`,children:a.refusal}):null]}):(0,G.jsxs)(`span`,{className:X(`flex min-w-0 items-center gap-1.5`,i),children:[(0,G.jsx)(`span`,{className:X(`truncate`,n),title:e.name,children:e.name}),(0,G.jsx)(vG,{count:r,className:`ml-auto`})]})}function EK({project:e}){return(0,G.jsx)(`span`,{"aria-hidden":!0,className:`block h-[22px] w-8 overflow-hidden rounded bg-background p-[5px]`,children:(0,G.jsx)(bK,{project:e,className:`size-full`})})}function DK({project:e,now:t,prefix:n}){return(0,G.jsxs)(`span`,{"data-edited":!0,className:`truncate text-body text-muted-foreground`,title:new Date(e.modifiedAt).toLocaleString(),children:[n,AK(Date.parse(e.modifiedAt),t)]})}function OK({project:e}){if(!e.createdAt)return(0,G.jsx)(`span`,{});let t=new Date(e.createdAt);return(0,G.jsx)(`time`,{dateTime:e.createdAt,className:`text-body text-muted-foreground`,title:t.toLocaleString(),children:jK(t)})}var kK=[[`year`,31536e3],[`month`,2592e3],[`week`,604800],[`day`,86400],[`hour`,3600],[`minute`,60]];function AK(e,t){let n=Math.max(0,(t-e)/1e3),r=new Intl.RelativeTimeFormat(`en`,{numeric:`auto`});for(let[e,t]of kK)if(n>=t)return r.format(-Math.floor(n/t),e);return`just now`}function jK(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}var MK=100;function NK(e=fetch){let t=tv(),n=Z(e=>e.connected),r=Z(e=>e.board),i=Z(e=>e.reloads),a=(0,y.useRef)(new Map);(0,y.useEffect)(()=>{a.current=new Map},[t,n]),(0,y.useEffect)(()=>{if(!n||!r)return;let o=new Map(PK(r).map(({ref:e,box:t})=>[e,`${t.width}x${t.height}#${i[e]??0}`]));if(![...o].some(([e,t])=>a.current.get(e)!==t))return;let s=setTimeout(()=>{for(let[e,t]of o)a.current.set(e,t);FK(e,t)},MK);return()=>clearTimeout(s)},[e,t,n,r,i])}function PK(e){return e.projects.flatMap(e=>(e.pages[0]?.frames??[]).filter(e=>!e.hidden))}async function FK(e,t){try{let n=await(await e(`/api/thumbnails?theme=${t}`)).json();n.ok&&n.data&&ml(yl,t,n.data.stamps)}catch{}}function IK({projects:e,calls:t}){let[n]=(0,y.useState)(Date.now),r=oK();return gK(t),NK(),(0,G.jsxs)(`div`,{className:`flex min-h-full flex-col text-body`,children:[(0,G.jsx)($G,{hasProjects:e.length>0}),e.length===0?(0,G.jsx)(iK,{}):(0,G.jsx)(SK,{projects:e,layout:r,now:n,calls:t})]})}var LK=1,RK=.9,zK=.8,BK=.17,VK=.1,HK=.999,UK=.9999,WK=.99,GK=/[\\\/_+.#"@\[\(\{&]/,KK=/[\\\/_+.#"@\[\(\{&]/g,qK=/[\s-]/,JK=/[\s-]/g;function YK(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?LK:WK;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=YK(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=LK:GK.test(e.charAt(l-1))?(d*=zK,p=e.slice(i,l-1).match(KK),p&&i>0&&(d*=HK**+p.length)):qK.test(e.charAt(l-1))?(d*=RK,m=e.slice(i,l-1).match(JK),m&&i>0&&(d*=HK**+m.length)):(d*=BK,i>0&&(d*=HK**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=UK)),(d<VK&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=YK(e,t,n,r,l+1,a+2,o),f*VK>d&&(d=f*VK)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function XK(e){return e.toLowerCase().replace(JK,` `)}function ZK(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,YK(e,t,XK(e),XK(t),0,0,{})}var QK=Object.defineProperty,$K=(e,t)=>QK(e,`name`,{value:t,configurable:!0}),eq=!!(typeof window<`u`&&window.document&&window.document.createElement);function tq(e,t,{checkForDefaultPrevented:n=!0}={}){return $K(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}$K(tq,`composeEventHandlers`);function nq(e){if(!eq)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}$K(nq,`getOwnerWindow`);function rq(e){if(!eq)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}$K(rq,`getOwnerDocument`);function iq(e,t=!1){let{activeElement:n}=rq(e);if(!n?.nodeName)return null;if(aq(n)&&n.contentDocument)return iq(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=rq(n).getElementById(e);if(t)return t}}return n}$K(iq,`getActiveElement`);function aq(e){return e.tagName===`IFRAME`}$K(aq,`isFrame`);var oq=Object.defineProperty,sq=(e,t)=>oq(e,`name`,{value:t,configurable:!0});function cq(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}sq(cq,`setRef`);function lq(...e){return t=>{let n=!1,r=e.map(e=>{let r=cq(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():cq(e[t],null)}}}}sq(lq,`composeRefs`);function uq(...e){return y.useCallback(lq(...e),e)}sq(uq,`useComposedRefs`);var dq=Object.defineProperty,fq=(e,t)=>dq(e,`name`,{value:t,configurable:!0});function pq(e,t){let n=y.createContext(t);n.displayName=e+`Context`;let r=fq(e=>{let{children:t,...r}=e,i=y.useMemo(()=>r,Object.values(r));return(0,G.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=y.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return fq(i,`useContext`),[r,i]}fq(pq,`createContext`);function mq(e,t=[]){let n=[];function r(t,r){let i=y.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=fq(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=y.useMemo(()=>o,Object.values(o));return(0,G.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=y.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return fq(s,`useContext`),[o,s]}fq(r,`createContext`);let i=fq(()=>{let t=n.map(e=>y.createContext(e));return fq(function(n){let r=n?.[e]||t;return y.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,hq(i,...t)]}fq(mq,`createContextScope`);function hq(...e){let t=e[0];if(e.length===1)return t;let n=fq(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return fq(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return y.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}fq(hq,`composeContextScopes`);var gq=globalThis?.document?y.useLayoutEffect:()=>{},_q=Object.defineProperty,vq=(e,t)=>_q(e,`name`,{value:t,configurable:!0}),yq=y.useId||(()=>void 0),bq=0;function xq(e){let[t,n]=y.useState(yq());return gq(()=>{e||n(e=>e??String(bq++))},[e]),e||(t?`radix-${t}`:``)}vq(xq,`useId`);var Sq=Object.defineProperty,Cq=(e,t)=>Sq(e,`name`,{value:t,configurable:!0}),wq=y.useEffectEvent,Tq=y.useInsertionEffect;function Eq(e){if(typeof wq==`function`)return wq(e);let t=y.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof Tq==`function`?Tq(()=>{t.current=e}):gq(()=>{t.current=e}),y.useMemo(()=>((...e)=>t.current?.(...e)),[])}Cq(Eq,`useEffectEvent`);var Dq=Object.defineProperty,Oq=(e,t)=>Dq(e,`name`,{value:t,configurable:!0}),kq=y.useInsertionEffect||gq;function Aq({prop:e,defaultProp:t,onChange:n=Oq(()=>{},`onChange`),caller:r}){let[i,a,o]=jq({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,y.useCallback(t=>{if(s){let n=Mq(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}Oq(Aq,`useControllableState`);function jq({defaultProp:e,onChange:t}){let[n,r]=y.useState(e),i=y.useRef(n),a=y.useRef(t);return kq(()=>{a.current=t},[t]),y.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}Oq(jq,`useUncontrolledState`);function Mq(e){return typeof e==`function`}Oq(Mq,`isFunction`);var Nq=Symbol(`RADIX:SYNC_STATE`);function Pq(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=Eq(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=y.useReducer((t,n)=>{if(n.type===Nq)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=y.useRef(p);y.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=y.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return y.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:Nq,state:i})},[i,d.state,c]),[h,f]}Oq(Pq,`useControllableStateReducer`);var Fq=Object.defineProperty,Iq=(e,t)=>Fq(e,`name`,{value:t,configurable:!0});function Lq(e){let t=y.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];r=qq(r),y.Children.forEach(r,e=>{if(Uq(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;for(;Gq(n)&&typeof Zq==`function`;)n=Zq(n._payload);a=Bq(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=y.cloneElement(a,void 0,s):!o&&y.Children.count(r)===1&&y.isValidElement(r)&&(a=r);let c=a?Hq(a):void 0,l=uq(n,c);if(!a){if(r||r===0)throw Error(o?Xq(e):Yq(e));return r}let u=Vq(i,a.props??{});return a.type!==y.Fragment&&(u.ref=n?l:c),y.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}Iq(Lq,`createSlot`);var Rq=Symbol.for(`radix.slottable`);function zq(e){let t=Iq(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=Rq,t}Iq(zq,`createSlottable`);var Bq=Iq((e,t)=>`child`in e.props?y.isValidElement(t)?y.cloneElement(t,void 0,e.props.children(t.props.children)):null:y.isValidElement(t)?t:null,`getSlottableElementFromSlottable`);function Vq(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`?n[r]=[i,a].filter(Boolean).join(` `):r===`aria-describedby`&&(n[r]=Jq(a,i))}return{...e,...n}}Iq(Vq,`mergeProps`);function Hq(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Iq(Hq,`getElementRef`);function Uq(e){return y.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Rq}Iq(Uq,`isSlottable`);var Wq=Symbol.for(`react.lazy`);function Gq(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Wq&&`_payload`in e&&Kq(e._payload)}Iq(Gq,`isLazyComponent`);function Kq(e){return typeof e==`object`&&!!e&&`then`in e}Iq(Kq,`isPromiseLike`);function qq(e){let t=e;for(;Gq(t)&&typeof Zq==`function`;)t=Zq(t._payload);return t}Iq(qq,`useUnwrappedLazy`);function Jq(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}Iq(Jq,`concatAriaDescribedby`);var Yq=Iq(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),Xq=Iq(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),Zq=y.use,Qq=Object.defineProperty,$q=(e,t)=>Qq(e,`name`,{value:t,configurable:!0}),eJ=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Lq(`Primitive.${t}`),r=y.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,G.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function tJ(e,t){e&&Gf.flushSync(()=>e.dispatchEvent(t))}$q(tJ,`dispatchDiscreteCustomEvent`);var nJ=Object.defineProperty,rJ=(e,t)=>nJ(e,`name`,{value:t,configurable:!0}),iJ=y.useInsertionEffect;function aJ(e){let t=y.useRef(e);return typeof iJ==`function`?iJ(()=>{t.current=e}):gq(()=>{t.current=e}),y.useMemo(()=>((...e)=>t.current?.(...e)),[])}rJ(aJ,`useCallbackRef`);var oJ=Object.defineProperty,sJ=(e,t)=>oJ(e,`name`,{value:t,configurable:!0}),cJ=`dismissableLayer.update`,lJ=`dismissableLayer.pointerDownOutside`,uJ=`dismissableLayer.focusOutside`,dJ,fJ=y.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),pJ=y.forwardRef(sJ(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=y.useContext(fJ),[d,f]=y.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=y.useState({}),h=uq(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,b=d?g.indexOf(d):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,S=b>=v,C=y.useRef(!1),w=gJ(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:y.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return S&&!t},[u.branches,S])}),T=_J(e=>{if(r&&C.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),E=d?b===g.length-1:!1,D=aJ(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return y.useEffect(()=>{if(E)return p.addEventListener(`keydown`,D,{capture:!0}),()=>p.removeEventListener(`keydown`,D,{capture:!0})},[p,E,D]),y.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(dJ=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),vJ(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=dJ))}},[d,p,n,u]),y.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),vJ())},[d,u]),y.useEffect(()=>{let e=sJ(()=>m({}),`handleUpdate`);return document.addEventListener(cJ,e),()=>document.removeEventListener(cJ,e)},[]),(0,G.jsx)(eJ.div,{...l,ref:h,style:{pointerEvents:x?S?`auto`:`none`:void 0,...e.style},onFocusCapture:tq(e.onFocusCapture,T.onFocusCapture),onBlurCapture:tq(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:tq(e.onPointerDownCapture,w.onPointerDownCapture)})},`DismissableLayer`));function mJ(){let e=y.useContext(fJ),[t,n]=y.useState(null);return y.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}sJ(mJ,`useDismissableLayerSurface`);var hJ=sJ(()=>!0,`IS_TRUE`);function gJ(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=hJ}=t,s=aJ(e),c=y.useRef(!1),l=y.useRef(!1),u=y.useRef(new Map),d=y.useRef(()=>{});return y.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}sJ(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}sJ(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}sJ(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}sJ(p,`handleInteractionBubble`);let m=sJ(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||yJ(lJ,s,p,{discrete:!0})};if(sJ(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:sJ(()=>c.current=!0,`onPointerDownCapture`)}}sJ(gJ,`usePointerDownOutside`);function _J(e,t=globalThis?.document){let n=aJ(e),r=y.useRef(!1);return y.useEffect(()=>{let e=sJ(e=>{e.target&&!r.current&&yJ(uJ,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:sJ(()=>r.current=!0,`onFocusCapture`),onBlurCapture:sJ(()=>r.current=!1,`onBlurCapture`)}}sJ(_J,`useFocusOutside`);function vJ(){let e=new CustomEvent(cJ);document.dispatchEvent(e)}sJ(vJ,`dispatchUpdate`);function yJ(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?tJ(i,a):i.dispatchEvent(a)}sJ(yJ,`handleAndDispatchCustomEvent`);var bJ=Object.defineProperty,xJ=(e,t)=>bJ(e,`name`,{value:t,configurable:!0}),SJ=`focusScope.autoFocusOnMount`,CJ=`focusScope.autoFocusOnUnmount`,wJ={bubbles:!1,cancelable:!0},TJ=y.forwardRef(xJ(function(e,t){let{loop:n=!1,trapped:r=!1,branches:i,onMountAutoFocus:a,onUnmountAutoFocus:o,...s}=e,[c,l]=y.useState(null),u=aJ(a),d=aJ(o),f=y.useRef(null),p=uq(t,l),m=y.useRef(i);y.useEffect(()=>{m.current=i});let h=y.useCallback(e=>e?c?.contains(e)?!0:!!m.current?.some(t=>t.contains(e)):!1,[c]),g=y.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;y.useEffect(()=>{if(r){let e=function(e){if(g.paused||!c)return;let t=e.target;h(t)?f.current=t:IJ(f.current,{select:!0})},t=function(e){if(g.paused||!c)return;let t=e.relatedTarget;t!==null&&(h(t)||IJ(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&IJ(c)};xJ(e,`handleFocusIn`),xJ(t,`handleFocusOut`),xJ(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,c,g.paused,h]),y.useEffect(()=>{if(c){LJ.add(g);let e=document.activeElement;if(!c.contains(e)){let t=new CustomEvent(SJ,wJ);c.addEventListener(SJ,u),c.dispatchEvent(t),t.defaultPrevented||(AJ(BJ(MJ(c)),{select:!0}),document.activeElement===e&&IJ(c))}return()=>{c.removeEventListener(SJ,u);let t=c.ownerDocument,n=CustomEvent;setTimeout(()=>{let r=new n(CJ,wJ);c.addEventListener(CJ,d),c.dispatchEvent(r),r.defaultPrevented||IJ(e??t.body,{select:!0}),c.removeEventListener(CJ,d),LJ.remove(g)},0)}}},[c,u,d,g]);let _=y.useCallback(e=>{if(!n&&!r||g.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=jJ(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&IJ(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&IJ(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,g.paused]);return(0,G.jsx)(eJ.div,{tabIndex:-1,...s,ref:p,onKeyDown:_})},`FocusScope`)),EJ=y.createContext(null);function DJ({registry:e,children:t}){return e?(0,G.jsx)(EJ.Provider,{value:e,children:t}):t}xJ(DJ,`FocusScopeBranchProvider`);function OJ(){let[e,t]=y.useState([]);return{nodes:e,registry:y.useMemo(()=>({add:xJ(e=>t(t=>t.includes(e)?t:[...t,e]),`add`),remove:xJ(e=>t(t=>t.filter(t=>t!==e)),`remove`)}),[])}}xJ(OJ,`useFocusScopeBranchRegistry`);function kJ(e){let t=y.useContext(EJ);y.useEffect(()=>{if(e&&t)return t.add(e),()=>t.remove(e)},[e,t])}xJ(kJ,`useFocusScopeBranch`);function AJ(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(IJ(r,{select:t}),document.activeElement!==n)return}xJ(AJ,`focusFirst`);function jJ(e){let t=MJ(e);return[NJ(t,e),NJ(t.reverse(),e)]}xJ(jJ,`getTabbableEdges`);function MJ(e){let t=[],n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:xJ(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}xJ(MJ,`getTabbableCandidates`);function NJ(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):PJ(r,{upTo:t})))return r}xJ(NJ,`findVisible`);function PJ(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}xJ(PJ,`isHidden`);function FJ(e){return e.tagName===`INPUT`&&typeof e.select==`function`}xJ(FJ,`isSelectableInput`);function IJ(e,{select:t=!1}={}){if(e&&e.focus){let n=(e.ownerDocument??document).activeElement;e.focus({preventScroll:!0}),e!==n&&FJ(e)&&t&&e.select()}}xJ(IJ,`focus`);var LJ=RJ();function RJ(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=zJ(e,t),e.unshift(t)},remove(t){e=zJ(e,t),e[0]?.resume()}}}xJ(RJ,`createFocusScopesStack`);function zJ(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}xJ(zJ,`arrayRemove`);function BJ(e){return e.filter(e=>e.tagName!==`A`)}xJ(BJ,`removeLinks`);var VJ=Object.defineProperty,HJ=y.forwardRef(((e,t)=>VJ(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=y.useState(!1);gq(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Gf.createPortal((0,G.jsx)(eJ.div,{...r,ref:t}),o):null},`Portal`)),UJ=Object.defineProperty,WJ=(e,t)=>UJ(e,`name`,{value:t,configurable:!0});function GJ(e,t){return y.useReducer((e,n)=>t[e][n]??e,e)}WJ(GJ,`useStateMachine`);var KJ=WJ(e=>{let{present:t,children:n}=e,r=qJ(t),i=typeof n==`function`?n({present:r.isPresent}):y.Children.only(n),a=YJ(r.ref,ZJ(i));return typeof n==`function`||r.isPresent?y.cloneElement(i,{ref:a}):null},`Presence`);function qJ(e){let[t,n]=y.useState(),r=y.useRef(null),i=y.useRef(e),a=y.useRef(`none`),o=y.useRef(void 0),[s,c]=GJ(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return y.useEffect(()=>{s===`mounted`?(a.current=o.current??XJ(r.current),o.current=void 0):a.current=`none`},[s]),gq(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=XJ(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),gq(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=WJ(a=>{let o=XJ(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=WJ(e=>{e.target===t&&(a.current=XJ(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:y.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=XJ(t)}else r.current=null;n(e)},[])}}WJ(qJ,`usePresence`);function JJ(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}WJ(JJ,`setRef`);function YJ(...e){let t=y.useRef(e);return t.current=e,y.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=JJ(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():JJ(n[e],null)}}},[])}WJ(YJ,`useStableComposedRefs`);function XJ(e){return e?.animationName||`none`}WJ(XJ,`getAnimationName`);function ZJ(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}WJ(ZJ,`getElementRef`);var QJ=Object.defineProperty,$J=(e,t)=>QJ(e,`name`,{value:t,configurable:!0}),eY=0,tY=null;function nY(e){return rY(),e.children}$J(nY,`FocusGuards`);function rY(){y.useEffect(()=>{tY||={start:iY(),end:iY()};let{start:e,end:t}=tY;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),eY++,()=>{eY===1&&(tY?.start.remove(),tY?.end.remove(),tY=null),eY=Math.max(0,eY-1)}},[])}$J(rY,`useFocusGuards`);function iY(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}$J(iY,`createFocusGuard`);var aY=function(){return aY=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},aY.apply(this,arguments)};function oY(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function sY(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var cY=`right-scroll-bar-position`,lY=`width-before-scroll-bar`,uY=`with-scroll-bars-hidden`,dY=`--removed-body-scroll-bar-size`;function fY(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function pY(e,t){var n=(0,y.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var mY=typeof window<`u`?y.useLayoutEffect:y.useEffect,hY=new WeakMap;function gY(e,t){var n=pY(t||null,function(t){return e.forEach(function(e){return fY(e,t)})});return mY(function(){var t=hY.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||fY(e,null)}),i.forEach(function(e){r.has(e)||fY(e,a)})}hY.set(n,e)},[e]),n}function _Y(e){return e}function vY(e,t){t===void 0&&(t=_Y);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function yY(e){e===void 0&&(e={});var t=vY(null);return t.options=aY({async:!0,ssr:!1},e),t}var bY=function(e){var t=e.sideCar,n=oY(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return y.createElement(r,aY({},n))};bY.isSideCarExport=!0;function xY(e,t){return e.useMedium(t),bY}var SY=yY(),CY=function(){},wY=y.forwardRef(function(e,t){var n=y.useRef(null),r=y.useState({onScrollCapture:CY,onWheelCapture:CY,onTouchMoveCapture:CY}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,b=e.gapMode,x=oY(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=f,C=gY([n,t]),w=aY(aY({},x),i);return y.createElement(y.Fragment,null,u&&y.createElement(S,{sideCar:SY,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:b}),o?y.cloneElement(y.Children.only(s),aY(aY({},w),{ref:C})):y.createElement(v,aY({},w,{className:c,ref:C}),s))});wY.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},wY.classNames={fullWidth:lY,zeroRight:cY};var TY=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function EY(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=TY();return t&&e.setAttribute(`nonce`,t),e}function DY(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function OY(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var kY=function(){var e=0,t=null;return{add:function(n){e==0&&(t=EY())&&(DY(t,n),OY(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},AY=function(){var e=kY();return function(t,n){y.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},jY=function(){var e=AY();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},MY={left:0,top:0,right:0,gap:0},NY=function(e){return parseInt(e||``,10)||0},PY=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[NY(n),NY(r),NY(i)]},FY=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return MY;var t=PY(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},IY=jY(),LY=`data-scroll-locked`,RY=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
72
- .${uY} {
67
+ `).map(e=>eH(e).catch(()=>null))).then(t=>{if(!e)return;let n=new Map;for(let e of t.flatMap(e=>e?.colors??[])){let t=`${e.token??e.value.toLowerCase()}:${e.percent}`;n.has(t)||n.set(t,e)}s({refs:i,colors:[...n.values()]})}),()=>{e=!1}},[i,a]),(0,G.jsx)(hH,{colors:o?.refs===i?o.colors:[],tokens:r,theme:n})}var xH=[{preset:`phone`,label:`Phone`,icon:Jn},{preset:`tablet`,label:`Tablet`,icon:nr},{preset:`desktop`,label:`Desktop`,icon:gn}];function SH(){let e=$F();return(0,G.jsxs)(`section`,{"aria-labelledby":`inspector-presets`,className:`border-b border-sidebar-border px-3 pt-2.5 pb-3`,children:[(0,G.jsx)(`h2`,{id:`inspector-presets`,className:`mb-2 text-xs font-semibold`,children:`Frame`}),(0,G.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":`inspector-presets`,className:`-mx-1.5 flex flex-col`,children:xH.map(({preset:t,label:n,icon:r})=>{let{width:i,height:a}=XF[t];return(0,G.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t===e,onClick:()=>eI(t),className:X(`flex h-[26px] items-center gap-1.5 rounded-md px-1.5 text-left outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/50`,t===e&&`bg-accent`),children:[(0,G.jsx)(r,{"aria-hidden":!0,className:`size-[13px] text-muted-foreground`,strokeWidth:1.6}),(0,G.jsx)(`span`,{className:`flex-1`,children:n}),(0,G.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[i,` × `,a]})]},t)})}),(0,G.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:`Click on the canvas to place it.`})]})}var CH=y.createContext(void 0);function wH(){let e=y.useContext(CH);if(e===void 0)throw Error(Ds(64));return e}var TH=`data-activation-direction`,EH={tabActivationDirection:e=>({[TH]:e})},DH=y.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,style:c,...l}=e,u=e.defaultValue!==void 0,d=y.useRef([]),[f,p]=y.useState(()=>new Map),[m,h]=hI({controlled:s,default:r,name:`Tabs`,state:`value`}),g=s!==void 0,[_,v]=y.useState(()=>new Map),b=y.useRef(void 0),x=y.useCallback(e=>OH(_,e),[_]),[S,C]=y.useState(()=>({previousValue:m,tabActivationDirection:`none`})),{previousValue:w,tabActivationDirection:T}=S,E=T,D=!1;w!==m&&(E=kH(w,m,a,_),D=w!=null&&m!=null&&x(m)==null);let O=D?w:m,k=w!==O||T!==E;Y(()=>{k&&C({previousValue:O,tabActivationDirection:E})},[O,k,E]);let A=J((e,t)=>{t.activationDirection=kH(m,e,a,_),i?.(e,t),!t.isCanceled&&h(()=>e)}),j=J((e,t)=>{i?.(e,jp(t,void 0,void 0,{activationDirection:`none`}))}),M=J((e,t)=>(p(n=>{let r=new Map(n);return r.set(e,t),r}),()=>{p(n=>{if(n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})})),N=y.useCallback(e=>f.get(e),[f]),P=y.useCallback(e=>{for(let t of _.values())if(e===t.value)return t.id},[_]),F=y.useMemo(()=>({getTabElementBySelectedValue:x,getTabIdByPanelValue:P,getTabPanelIdByValue:N,onValueChange:A,orientation:a,registerMountedTabPanel:M,setTabMap:v,tabActivationDirection:E,value:m}),[x,P,N,A,a,M,v,E,m]),I=y.useMemo(()=>{for(let e of _.values())if(e.value===m)return e},[_,m]),L=y.useMemo(()=>{for(let e of _.values())if(!e.disabled)return e.value},[_]),R=y.useRef(!u),z=y.useRef(r),B=y.useRef(u),ee=y.useRef(!1);Y(()=>{if(g)return;function e(e,t){h(()=>e),C({previousValue:e,tabActivationDirection:`none`}),j(e,t),R.current=!1}if(_.size===0){ee.current&&m!==null&&!b.current?.isConnected&&e(null,Jp);return}ee.current=!0,b.current=_.keys().next().value;let t=I?.disabled,n=I==null&&m!==null;if(!t&&m===z.current&&(B.current=!1),B.current&&t&&m===z.current)return;let r=R.current;if(t||n){let n=L??null;if(m===n){R.current=!1;return}let i=Jp;r?i=Yp:t&&(i=qp),e(n,i)}else r&&I!=null&&(j(m,Yp),R.current=!1)},[L,g,j,I,h,_,m]);let te=Zs(`div`,e,{state:{orientation:a,tabActivationDirection:E},ref:t,props:l,stateAttributesMapping:EH});return(0,G.jsx)(CH.Provider,{value:F,children:(0,G.jsx)(uL,{elementsRef:d,children:te})})});function OH(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function kH(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=OH(r,e),c=OH(r,t);if(s==null||c==null)return s!==c&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?t>e?o:a:`none`;let l=s.getBoundingClientRect()[i],u=c.getBoundingClientRect()[i];return u<l?a:u>l?o:`none`}var AH=`data-composite-item-active`,jH=y.createContext(void 0);function MH(){let e=y.useContext(jH);if(e===void 0)throw Error(Ds(65));return e}var NH=y.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,style:c,...l}=e,{value:u,getTabPanelIdByValue:d,onValueChange:f,orientation:p,tabActivationDirection:m}=wH(),{activateOnFocus:h,registerTabResizeObserverElement:g,tabsListElement:_}=MH(),{highlightedIndex:v,onHighlightedIndexChange:b}=ks(),x=OI(o),{compositeProps:S,compositeRef:C,index:w}=lR({metadata:y.useMemo(()=>({disabled:r,id:x,value:a}),[r,x,a])}),T=a===u,E=y.useRef(!1),D=y.useRef(null),O=J(e=>{D.current?.(),D.current=e?g(e):null});Y(()=>{if(E.current){E.current=!1;return}if(!(T&&w>-1&&v!==w))return;let e=_;if(e!=null){let t=Nu(js(e));if(t&&Q(e,t))return}r||b(w)},[T,w,v,b,r,_]);let{getButtonProps:k,buttonRef:A}=Ns({disabled:r,native:s,focusableWhenDisabled:!0}),j=d(a),M=y.useRef(!1),N=y.useRef(!1);function P(e){f(a,jp(Np,e.nativeEvent,void 0,{activationDirection:`none`}))}function F(e){T||r||P(e)}function I(e){T||r||h&&(!M.current||N.current)&&P(e)}function L(e){if(T||r)return;M.current=!0,N.current=e.button===0;let t=js(e.currentTarget);function n(){M.current=!1,N.current=!1,t.removeEventListener(`pointerup`,n),t.removeEventListener(`pointercancel`,n)}t.addEventListener(`pointerup`,n),t.addEventListener(`pointercancel`,n)}return Zs(`button`,e,{state:{disabled:r,active:T,orientation:p,tabActivationDirection:m},ref:[t,A,C,O],props:[S,{role:`tab`,"aria-controls":j,"aria-selected":T,id:x,onClick:F,onFocus:I,onPointerDown:L,[AH]:T?``:void 0,onKeyDownCapture(){E.current=!0}},l,k],stateAttributesMapping:EH})}),PH=`data-index`,FH={...EH,...Ku},IH=y.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:a=!1,style:o,...s}=e,{value:c,getTabIdByPanelValue:l,orientation:u,tabActivationDirection:d,registerMountedTabPanel:f}=wH(),p=OI(),{ref:m,index:h}=DI(),g=r===c,{mounted:_,transitionStatus:v,setMounted:b}=th(g),x=!_,S=l(r),C={hidden:x,orientation:u,tabActivationDirection:d,transitionStatus:v},w=y.useRef(null),T=Zs(`div`,e,{state:C,ref:[t,m,w],props:[{"aria-labelledby":S,hidden:x,id:p,role:`tabpanel`,tabIndex:g?0:-1,inert:Bf(!g),[PH]:h},s],stateAttributesMapping:FH});return Yf({open:g,ref:w,onComplete(){g||b(!1)}}),Y(()=>{if(!(p==null||x&&!a))return f(r,p)},[x,a,r,p,f]),a||_?T:null});function LH(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=Ks}=e,[p,m]=y.useState(0),h=r!=null,g=y.useRef(null),_=Is(g,c),v=y.useRef([]),b=y.useRef(!1),x=y.useRef(null),S=o??p,C=J((e,t=!1)=>{if(x.current=v.current[e]??null,(s??m)(e),t){let t=v.current[e];YI(g.current,t,a,n)}}),w=J(e=>{if(e.size===0)return;if(b.current){let e=v.current,t=e.indexOf(x.current);if(t===-1){let t=e[S];!t||nf(e,S,d)?C(RH(e,d)):x.current=t}else t!==S&&C(t);return}b.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)C(i);else if(nf(t,S,d)){let e=tf(t,{disabledIndices:d});Zd(t,e)||C(e)}YI(g.current,r,a,n)});Y(()=>{if(d==null||o!=null||!b.current)return;let e=v.current;if(nf(e,S,d)){let t=tf(e,{disabledIndices:d});Zd(e,t)||C(t)}},[d,o,S,v,C]);let T=J((e,t,n)=>i?i(e,t,n,v):n),E=J(e=>{let o=e.key===`Home`||e.key===`End`;if(!GI.has(e.key)||!l&&o||zH(e,f)||!g.current)return;let s=a===`rtl`,c=s?UI:WI,p=s?WI:UI,m=n===`vertical`?HI:c,_=n===`vertical`?VI:p,y=Fu(e.nativeEvent);if(y!=null&&JI(y)&&!vR(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let b=S,x=Qd(v,d),w=$d(v,d);r!=null&&(b=r({disabledIndices:d,elementsRef:v,event:e,highlightedIndex:S,loopFocus:t,maxIndex:w,minIndex:x,onLoop:T,orientation:n,rtl:s}));let E=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,D=n!==`vertical`&&e.key===p||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?b=x:e.key===`End`&&(b=w)),b===S&&(E||D)&&(t&&b===w&&E?(b=x,i&&(b=i(e,S,b,v))):t&&b===x&&D?(b=w,i&&(b=i(e,S,b,v))):b=tf(v.current,{startingIndex:b,decrement:D,disabledIndices:d})),b!==S&&!Zd(v.current,b)&&(u&&e.stopPropagation(),(h||o||E||D)&&e.preventDefault(),C(b,!0),queueMicrotask(()=>{v.current[b]?.focus()}))});return{props:{ref:_,onFocus(e){let t=g.current,n=Fu(e.nativeEvent);t&&n!=null&&JI(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:E},highlightedIndex:S,onHighlightedIndexChange:C,elementsRef:v,onMapChange:w,relayKeyboardEvent:E}}function RH(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!nf(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function zH(e,t){for(let n of KI)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function BH(e){let{render:t,className:n,style:r,refs:i=Ks,props:a=Ks,state:o=qs,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:b,highlightItemOnHover:x=!1,tag:S=`div`,...C}=e,{props:w,highlightedIndex:T,onHighlightedIndexChange:E,elementsRef:D,onMapChange:O,relayKeyboardEvent:k}=LH({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:a_(),disabledIndices:v,modifierKeys:b}),A=Zs(S,e,{state:o,ref:i,props:[w,...a,C],stateAttributesMapping:s}),j=y.useMemo(()=>({highlightedIndex:T,onHighlightedIndexChange:E,highlightItemOnHover:x,relayKeyboardEvent:k}),[T,E,x,k]);return(0,G.jsx)(Os.Provider,{value:j,children:(0,G.jsx)(uL,{elementsRef:D,onMapChange:e=>{h?.(e),O(e)},children:A})})}var VH=y.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,style:o,...s}=e,{orientation:c,setTabMap:l,tabActivationDirection:u}=wH(),[d,f]=y.useState(0),[p,m]=y.useState(null),h=y.useRef(new Set),g=y.useRef(new Set),_=y.useRef(null);Y(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{h.current.forEach(e=>{e()})});return _.current=e,p&&e.observe(p),g.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),_.current=null}},[p]);let v=J(e=>(h.current.add(e),()=>{h.current.delete(e)})),b=J(e=>(g.current.add(e),_.current?.observe(e),()=>{g.current.delete(e),_.current?.unobserve(e)})),x={orientation:c,tabActivationDirection:u},S={"aria-orientation":c===`vertical`?`vertical`:void 0,role:`tablist`},C=y.useMemo(()=>({activateOnFocus:n,registerIndicatorUpdateListener:v,registerTabResizeObserverElement:b,tabsListElement:p}),[n,v,b,p]);return(0,G.jsx)(jH.Provider,{value:C,children:(0,G.jsx)(BH,{render:a,className:r,style:o,state:x,refs:[t,m],props:[S,s],stateAttributesMapping:EH,highlightedIndex:d,enableHomeAndEndKeys:!0,loopFocus:i,orientation:c,onHighlightedIndexChange:f,onMapChange:l,disabledIndices:Ks})})});function HH({className:e,orientation:t=`horizontal`,...n}){return(0,G.jsx)(DH,{"data-slot":`tabs`,"data-orientation":t,className:X(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var UH=lc(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function WH({className:e,variant:t=`default`,...n}){return(0,G.jsx)(VH,{"data-slot":`tabs-list`,"data-variant":t,className:X(UH({variant:t}),e),...n})}function GH({className:e,...t}){return(0,G.jsx)(NH,{"data-slot":`tabs-trigger`,className:X(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function KH({className:e,...t}){return(0,G.jsx)(IH,{"data-slot":`tabs-content`,className:X(`flex-1 text-sm outline-none`,e),...t})}var qH=null;function JH(e,t){let[n=``,r=``]=e.split(`/`),i=z(n,r);if(qH?.(),qH=null,t(),YH(i)&&OD.attached()){XH();return}let a=OD.onAttach(()=>{OD.attached()&&(a(),qH=null,XH())});qH=a,F(i)}function YH(e){return decodeURIComponent(location.pathname)===decodeURIComponent(e)}function XH(){we(`view.zoomToSelection`)?.run()}function ZH(e,t,n=bD,r=cH){let i=`${e}/${t.page}`,{index:a,hash:o}=t;JH(i,()=>{let e=r(t.ref),s=e!==null&&e!==o&&!_D(t.ref,e);a===null||o===null||s?sD(n,i,[t.ref]):cD(n,i,{frame:t.ref,index:a,hash:o})})}function QH(e,t,n,r=eU){let[i,a]=(0,y.useState)(null),o=(0,y.useRef)(0),s=(0,y.useRef)(n);(0,y.useEffect)(()=>{s.current=n},[n]);let c=Z(t=>$H(t.reloads,e)),l=t.trim()===``,u=`${c}\n${e}\n${t}`;if((0,y.useEffect)(()=>{let n=++o.current;if(l)return;let i=setTimeout(()=>{r(e,t).then(e=>{n===o.current&&a({key:u,status:`ready`,result:e,lead:s.current})},e=>{if(n!==o.current)return;let t=e instanceof Error?e.message:String(e);a({key:u,status:`refused`,message:t})})},120);return()=>clearTimeout(i)},[e,t,l,u,r]),l)return{status:`idle`};if(i?.status===`ready`){let{result:e,lead:t}=i;return{status:`ready`,result:e,lead:t,updating:i.key!==u}}return i?.status===`refused`&&i.key===u?i:{status:`loading`}}function $H(e,t){let n=0;for(let[r,i]of Object.entries(e))r.startsWith(`${t}/`)&&(n+=i);return n}async function eU(e,t,n=fetch){let r=await n(`/api/find?${new URLSearchParams({project:e,q:t})}`),i=await r.json().catch(()=>null);if(!i)throw Error(`The board answered ${r.status}.`);if(!i.ok)throw Error(i.error.message);return i.data}var tU=[{value:`all`,label:`All`},{value:`frame`,label:`Frames`},{value:`element`,label:`Elements`},{value:`text`,label:`Text`}],nU={frame:Xn,element:In,text:mr},rU={frame:`frame`,element:`element`,text:`text`};function iU({project:e,page:t,load:n,pick:r=ZH}){let[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(`all`),[c,l]=(0,y.useState)(null),u=(0,y.useRef)(null),d=qB(e=>e.focusRequest),f=QH(e,i,t,n),p=(0,y.useId)();(0,y.useEffect)(()=>{u.current?.focus(),u.current?.select()},[d]);let m=cU(f.status===`ready`?f.result.hits.filter(e=>o===`all`||e.kind===o):[],f.status===`ready`?f.lead:``),h=m.flatMap(e=>e.hits),g=h.find(e=>lU(e)===c)??h[0]??null,_=e=>`${p}-${lU(e)}`,v=t=>{l(lU(t)),r(e,t)};return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col text-xs`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),YB())},children:[(0,G.jsxs)(`div`,{className:`m-2 flex shrink-0 items-center gap-1.5`,children:[(0,G.jsxs)(`label`,{className:`flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-[7px] bg-muted px-2 focus-within:ring-[1.5px] focus-within:ring-primary`,children:[(0,G.jsx)(Kn,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,G.jsx)(`input`,{ref:u,role:`combobox`,"aria-label":`Find in ${e}`,"aria-expanded":h.length>0,"aria-controls":p,"aria-autocomplete":`list`,"aria-activedescendant":g?_(g):void 0,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),h.length===0)return;let t=g?h.indexOf(g):-1,n=e.key===`ArrowDown`?1:-1,r=h[(t+n+h.length)%h.length];r&&l(lU(r))}else e.key===`Enter`&&g&&(e.preventDefault(),v(g))},spellCheck:!1,autoComplete:`off`,className:`min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none`})]}),(0,G.jsx)(`button`,{type:`button`,"aria-label":i===``?`Close find`:`Clear the search`,onClick:()=>{i===``?YB():(a(``),u.current?.focus())},className:`grid size-[26px] shrink-0 place-items-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 active:bg-accent`,children:(0,G.jsx)(br,{"aria-hidden":!0,className:`size-3.5`})})]}),(0,G.jsx)(`div`,{role:`group`,"aria-label":`Show`,className:`flex shrink-0 gap-1 px-2 pb-1.5`,children:tU.map(e=>(0,G.jsx)(`button`,{type:`button`,"aria-pressed":o===e.value,onClick:()=>s(e.value),className:X(`flex h-[22px] items-center rounded-full px-2 text-[11px] outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,o===e.value?`bg-foreground text-sidebar`:`bg-muted text-muted-foreground hover:bg-accent hover:text-foreground`),children:e.label},e.value))}),(0,G.jsx)(`div`,{id:p,role:`listbox`,"aria-label":`Matches`,"aria-busy":f.status===`ready`&&f.updating,className:X(`min-h-0 overflow-y-auto pb-1`,f.status===`ready`&&f.updating&&`opacity-60`),children:m.map(e=>(0,G.jsxs)(`div`,{role:`group`,"aria-labelledby":`${p}-${e.page}`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between px-3 pt-2 pb-0.5 text-[11px] font-semibold text-faint`,children:[(0,G.jsx)(`span`,{id:`${p}-${e.page}`,children:e.page}),(0,G.jsx)(`span`,{children:e.hits.length})]}),e.hits.map(e=>(0,G.jsx)(aU,{id:_(e),hit:e,query:i,active:e===g,onPick:()=>v(e)},lU(e)))]},e.page))}),(0,G.jsx)(oU,{answer:f,project:e,shown:h.length,filter:o,onShowAll:()=>s(`all`)}),(0,G.jsx)(`p`,{className:`shrink-0 px-3 pt-2 pb-3 text-[11px] text-faint`,children:`Esc goes back to the layers`})]})}function aU({id:e,hit:t,query:n,active:r,onPick:i}){let a=nU[t.kind],o=t.kind===`text`?`Text in ${t.frame}`:(0,G.jsx)(sU,{text:t.name,query:n}),s=t.kind===`text`?(0,G.jsxs)(G.Fragment,{children:[`“`,(0,G.jsx)(sU,{text:t.snippet??``,query:n}),`”`]}):t.kind===`element`?`in ${t.frame}`:rU.frame;return(0,G.jsxs)(`div`,{id:e,role:`option`,"aria-selected":r,onMouseDown:e=>e.preventDefault(),onClick:i,className:X(`mx-1.5 flex items-start gap-2 rounded-md px-2 py-[5px] text-foreground hover:bg-sidebar-accent`,r&&`bg-accent`),children:[(0,G.jsx)(a,{"aria-hidden":!0,className:`mt-px size-[13px] shrink-0 text-muted-foreground`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate`,children:o}),(0,G.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:s})]})]})}function oU({answer:e,project:t,shown:n,filter:r,onShowAll:i}){let a=`shrink-0 px-3 pt-2 text-[11px]`;if(e.status===`idle`)return(0,G.jsxs)(`p`,{className:X(a,`text-muted-foreground`),children:[`Type to find frames, elements, and text across every page of `,t,`.`]});if(e.status===`loading`)return null;if(e.status===`refused`)return(0,G.jsx)(`p`,{role:`alert`,className:X(a,`text-destructive`),children:e.message});let{hits:o,truncated:s,query:c}=e.result;return o.length===0?(0,G.jsxs)(`p`,{className:X(a,`text-muted-foreground`),children:[`Nothing in `,t,` matches “`,c.trim(),`”.`]}):n===0&&r!==`all`?(0,G.jsxs)(`p`,{className:X(a,`text-muted-foreground`),children:[s?`The first ${o.length} matches hold no ${rU[r]}. Type more to narrow them.`:`No ${rU[r]} matches.`,` `,(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-foreground underline underline-offset-2 outline-none hover:text-primary focus-visible:ring-3 focus-visible:ring-ring/50`,children:`Show all`})]}):s?(0,G.jsxs)(`p`,{className:X(a,`text-muted-foreground`),children:[`Showing the first `,o.length,` matches. Type more to narrow them.`]}):null}function sU({text:e,query:t}){let n=t.trim().toLowerCase(),r=n===``?-1:e.toLowerCase().indexOf(n);return r===-1?(0,G.jsx)(G.Fragment,{children:e}):(0,G.jsxs)(G.Fragment,{children:[e.slice(0,r),(0,G.jsx)(`mark`,{className:`rounded-[2px] bg-primary/35 text-foreground`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}function cU(e,t){let n=[];for(let t of e){let e=n.find(e=>e.page===t.page);e?e.hits.push(t):n.push({page:t.page,hits:[t]})}let r=n.findIndex(e=>e.page===t);return r>0&&n.unshift(...n.splice(r,1)),n}function lU(e){return`${e.kind}:${e.ref}:${e.index??``}`}function uU(e){let t=(0,y.useRef)(!1);return{onKeyDown:e=>{if(!(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey))return;e.preventDefault(),e.stopPropagation(),t.current=!0;let n=e.currentTarget.getBoundingClientRect();e.currentTarget.dispatchEvent(new MouseEvent(`contextmenu`,{bubbles:!0,cancelable:!0,clientX:n.left+n.width/2,clientY:n.top+n.height/2}))},onOpenChangeComplete:n=>{n&&t.current&&(t.current=!1,e.current?.querySelector(`[role="menuitem"]:not([aria-disabled="true"])`)?.focus())}}}var dU=[`view.zoomToSelection`,`frame.duplicate`,`frame.hide`,`frame.lock`,`frame.delete`];function fU({frame:e,page:t,trigger:n}){let r=Ce(dU),[i,a,o,s,c]=xD(n=>n.page===t&&!n.element&&n.frames.includes(e.ref))?r:r.map(()=>void 0),l=Z(e=>e.canWrite),u=(0,y.useRef)(null),d=uU(u);return(0,G.jsxs)(ER,{onOpenChange:n=>{if(!n||e.hidden||iD.getState().mode!==`edit`)return;let{page:r,frames:i,element:a}=bD.getState();(a||r!==t||!i.includes(e.ref))&&sD(bD,t,[e.ref])},onOpenChangeComplete:d.onOpenChangeComplete,children:[(0,G.jsx)(DR,{render:n,onKeyDown:d.onKeyDown}),(0,G.jsxs)(OR,{ref:u,className:`w-55`,children:[(0,G.jsxs)(kR,{children:[(0,G.jsx)(IR,{children:`Frame in layers`}),(0,G.jsx)(PR,{action:i,children:`Zoom to frame`}),(0,G.jsx)(PR,{action:{id:`layers.rename`,label:`Rename`,group:`frame`,enabled:()=>l&&iD.getState().mode===`edit`,run:()=>GF(e.ref,`layers`)}}),(0,G.jsx)(PR,{action:a,children:`Duplicate`}),(0,G.jsx)(PR,{action:o,children:`Hide`}),(0,G.jsx)(PR,{action:s,children:s?.checked?.()?`Unlock`:`Lock`})]}),(0,G.jsx)(MR,{}),(0,G.jsx)(FR,{action:c})]})]})}function pU({page:e,element:t,trigger:n}){let r=(0,y.useRef)(null),i=uU(r);return(0,G.jsxs)(ER,{onOpenChange:n=>{n&&cD(bD,e,t)},onOpenChangeComplete:i.onOpenChangeComplete,children:[(0,G.jsx)(DR,{render:n,onKeyDown:i.onKeyDown}),(0,G.jsx)(OR,{ref:r,className:`w-[230px]`,children:(0,G.jsx)(WR,{noteable:!1})})]})}function mU({edge:e}){return e===null?null:(0,G.jsx)(`span`,{"aria-hidden":!0,className:X(`pointer-events-none absolute right-1.5 left-5 z-10 h-0.5 rounded-[1px] bg-primary`,`before:absolute before:-top-[3px] before:-left-[5px] before:size-2 before:rounded-full before:border-2 before:border-primary before:bg-sidebar before:content-['']`,e===`top`?`-top-px`:`-bottom-px`)})}var hU=14,gU=8;function _U({frame:e,page:t,selected:n,frameSelected:r,isOpen:i,toggle:a}){let o=PP(e.ref);if(!o||o.status===`loading`)return(0,G.jsx)(vU,{depth:1,children:`Reading elements`});if(o.status===`refused`)return(0,G.jsx)(vU,{depth:1,title:o.message,children:`This frame cannot be addressed`});let{tree:s}=o,c=yU(s.elements,i);if(c.length===0)return(0,G.jsx)(vU,{depth:1,children:`No elements`});let l=new Set(s.elements.map(e=>e.parent));return(0,G.jsx)(`ul`,{"aria-label":`Elements of ${e.name}`,children:c.map(({element:o,depth:c})=>{let u=i(o.index),d=o.index===n,f=o.textOnly?mr:In;return(0,G.jsx)(pU,{page:t,element:{frame:e.ref,index:o.index,hash:s.hash},trigger:(0,G.jsxs)(`li`,{className:X(`flex h-[26px] items-center gap-1.5 pr-2 text-foreground`,d?`bg-primary/26`:r?`bg-primary/13`:n===null?`hover:bg-accent`:`bg-primary/7`),style:{paddingLeft:gU+c*hU},children:[l.has(o.index)?(0,G.jsx)(`button`,{type:`button`,"aria-label":`${u?`Hide`:`Show`} what ${o.name} holds`,"aria-expanded":u,onClick:()=>a(o.index),className:`grid w-2.5 shrink-0 place-items-center text-faint outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:u?(0,G.jsx)(dt,{"aria-hidden":!0,className:`size-2.5`}):(0,G.jsx)(pt,{"aria-hidden":!0,className:`size-2.5`})}):(0,G.jsx)(`span`,{"aria-hidden":!0,className:`w-2.5 shrink-0`}),(0,G.jsxs)(`button`,{type:`button`,"aria-current":d?`true`:void 0,onClick:()=>cD(bD,t,{frame:e.ref,index:o.index,hash:s.hash}),className:`flex min-w-0 flex-1 items-center gap-1.5 self-stretch text-left outline-none focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset`,children:[(0,G.jsx)(f,{"aria-hidden":!0,className:X(`size-[13px] shrink-0`,d?`text-primary`:`text-muted-foreground`)}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:o.name,children:o.name})]})]})},o.index)})})}function vU({depth:e,title:t,children:n}){return(0,G.jsx)(`p`,{title:t,className:`flex h-[26px] items-center truncate pr-2 text-faint`,style:{paddingLeft:gU+e*hU+16},children:n})}function yU(e,t){let n=new Map,r=[];for(let i of e){if(i.parent===null){n.set(i.index,1),r.push({element:i,depth:1});continue}let e=n.get(i.parent);e!==void 0&&t(i.parent)&&(n.set(i.index,e+1),r.push({element:i,depth:e+1}))}return r}function bU(e){if(Array.isArray(e))return e}function xU(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function SU(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function CU(e,t){if(e){if(typeof e==`string`)return SU(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?SU(e,t):void 0}}function wU(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
68
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function TU(e,t){return bU(e)||xU(e,t)||CU(e,t)||wU()}var EU=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.bind=void 0;function t(e,t){var n=t.type,r=t.listener,i=t.options;return e.addEventListener(n,r,i),function(){e.removeEventListener(n,r,i)}}e.bind=t})),DU=o(((e,t,n)=>{var r=n&&n.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.bindAll=void 0;var i=EU();function a(e){if(e!==void 0)return typeof e==`boolean`?{capture:e}:e}function o(e,t){return t==null?e:r(r({},e),{options:r(r({},a(t)),a(e.options))})}function s(e,t,n){var r=t.map(function(t){var r=o(t,n);return(0,i.bind)(e,r)});return function(){r.forEach(function(e){return e()})}}e.bindAll=s})),OU=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.bindAll=e.bind=void 0;var t=EU();Object.defineProperty(e,"bind",{enumerable:!0,get:function(){return t.bind}});var n=DU();Object.defineProperty(e,"bindAll",{enumerable:!0,get:function(){return n.bindAll}})}))(),kU=`data-pdnd-honey-pot`;function AU(e){return e instanceof Element&&e.hasAttribute(`data-pdnd-honey-pot`)}function jU(e){var t=TU(document.elementsFromPoint(e.x,e.y),2),n=t[0],r=t[1];return n?AU(n)?r??null:n:null}function MU(e){"@babel/helpers - typeof";return MU=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},MU(e)}function NU(e,t){if(MU(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(MU(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function PU(e){var t=NU(e,`string`);return MU(t)==`symbol`?t:t+``}function FU(e,t,n){return(t=PU(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var IU=2147483647,LU={inset:`unset`,border:`none`,padding:0,margin:0,overflow:`visible`,color:`inherit`,background:`transparent`,width:`auto`,height:`auto`};function RU(e){var t=null;return function(){if(!t){var n=[...arguments];t={result:e.apply(this,n)}}return t.result}}var zU=RU(function(){return typeof HTMLElement<`u`&&typeof HTMLElement.prototype.showPopover==`function`});function BU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function VU(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?BU(Object(n),!0).forEach(function(t){FU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):BU(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var HU=2,UU=HU/2;function WU(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}function GU(e){return{x:e.x-UU,y:e.y-UU}}function KU(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}function qU(e){return{x:Math.min(e.x,window.innerWidth-HU),y:Math.min(e.y,window.innerHeight-HU)}}function JU(e){var t=e.client,n=qU(KU(GU(WU(t))));return DOMRect.fromRect({x:n.x,y:n.y,width:HU,height:HU})}function YU(e){var t=e.clientRect;return{left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`}}function XU(e){var t=e.client,n=e.clientRect;return t.x>=n.x&&t.x<=n.x+n.width&&t.y>=n.y&&t.y<=n.y+n.height}function ZU(e){var t=e.initial,n=document.createElement(`div`);n.setAttribute(kU,`true`),zU()&&n.setAttribute(`popover`,`manual`);var r=JU({client:t});Object.assign(n.style,VU(VU({position:`fixed`},zU()?LU:{zIndex:IU}),{},{backgroundColor:`transparent`,padding:0,margin:0,boxSizing:`border-box`,pointerEvents:`auto`},YU({clientRect:r}))),document.body.appendChild(n),zU()&&n.showPopover();var i=(0,OU.bind)(window,{type:`pointermove`,listener:function(e){r=JU({client:{x:e.clientX,y:e.clientY}}),Object.assign(n.style,YU({clientRect:r}))},options:{capture:!0}});return function(e){var t=e.current;if(i(),XU({client:t,clientRect:r})){n.remove();return}function a(){o(),n.remove()}var o=(0,OU.bindAll)(window,[{type:`pointerdown`,listener:a},{type:`pointermove`,listener:a},{type:`focusin`,listener:a},{type:`focusout`,listener:a},{type:`dragstart`,listener:a},{type:`dragenter`,listener:a},{type:`dragover`,listener:a}],{capture:!0})}}function QU(){var e=null;function t(){return e=null,(0,OU.bind)(window,{type:`pointermove`,listener:function(t){e={x:t.clientX,y:t.clientY}},options:{capture:!0}})}function n(){var t=null;return function(n){var r=n.eventName,i=n.payload;if(r===`onDragStart`){var a=i.location.initial.input;t=ZU({initial:e??{x:a.clientX,y:a.clientY}})}if(r===`onDrop`){var o,s=i.location.current.input;(o=t)==null||o({current:{x:s.clientX,y:s.clientY}}),t=null,e=null}}}return{bindEvents:t,getOnPostDispatch:n}}function $U(e){if(Array.isArray(e))return SU(e)}function eW(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function tW(){throw TypeError(`Invalid attempt to spread non-iterable instance.
69
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nW(e){return $U(e)||eW(e)||CU(e)||tW()}var rW=RU(function(){return navigator.userAgent.includes(`Firefox`)}),iW=RU(function(){var e=navigator.userAgent;return e.includes(`AppleWebKit`)&&!e.includes(`Chrome`)});function aW(e){return`nodeName`in e}function oW(e){return aW(e)&&e.ownerDocument!==document}var sW={isLeavingWindow:Symbol(`leaving`),isEnteringWindow:Symbol(`entering`)};(function(){if(typeof window>`u`||!iW())return;function e(){return{enterCount:0,isOverWindow:!1}}var t=e();function n(){t=e()}(0,OU.bindAll)(window,[{type:`dragstart`,listener:function(){t.enterCount=0,t.isOverWindow=!0}},{type:`drop`,listener:n},{type:`dragend`,listener:n},{type:`dragenter`,listener:function(e){!t.isOverWindow&&t.enterCount===0&&(e[sW.isEnteringWindow]=!0),t.isOverWindow=!0,t.enterCount++}},{type:`dragleave`,listener:function(e){t.enterCount--,t.isOverWindow&&t.enterCount===0&&(e[sW.isLeavingWindow]=!0,t.isOverWindow=!1)}}],{capture:!0})})();function cW(e){var t=e.dragLeave;return iW()?t.hasOwnProperty(sW.isLeavingWindow):!1}function lW(e){var t=e.dragLeave,n=t.type,r=t.relatedTarget;return n===`dragleave`?iW()?cW({dragLeave:t}):r==null?!0:rW()?oW(r):r instanceof HTMLIFrameElement:!1}function uW(e){var t=e.onDragEnd;return[{type:`pointermove`,listener:function(){var e=0;return function(){e<20?e++:t()}}()},{type:`pointerdown`,listener:t}]}function dW(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}var fW=function(e){var t=[],n=null,r=function(){t=[...arguments],!n&&(n=requestAnimationFrame(function(){n=null,e.apply(void 0,t)}))};return r.cancel=function(){n&&=(cancelAnimationFrame(n),null)},r}(function(e){return e()}),pW=function(){var e=null;function t(t){e={frameId:requestAnimationFrame(function(){e=null,t()}),fn:t}}function n(){e&&=(cancelAnimationFrame(e.frameId),e.fn(),null)}return{schedule:t,flush:n}}();function mW(e){var t=e.source,n=e.initial,r=e.dispatchEvent,i={dropTargets:[]};function a(e){r(e),i={dropTargets:e.payload.location.current.dropTargets}}return{start:function(e){var r=e.nativeSetDragImage,o={current:n,previous:i,initial:n};a({eventName:`onGenerateDragPreview`,payload:{source:t,location:o,nativeSetDragImage:r}}),pW.schedule(function(){a({eventName:`onDragStart`,payload:{source:t,location:o}})})},dragUpdate:function(e){var r=e.current;pW.flush(),fW.cancel(),a({eventName:`onDropTargetChange`,payload:{source:t,location:{initial:n,previous:i,current:r}}})},drag:function(e){var r=e.current;fW(function(){pW.flush(),a({eventName:`onDrag`,payload:{source:t,location:{initial:n,previous:i,current:r}}})})},drop:function(e){var r=e.current,o=e.updatedSourcePayload;pW.flush(),fW.cancel(),a({eventName:`onDrop`,payload:{source:o??t,location:{current:r,previous:i,initial:n}}})}}}var hW={isActive:!1};function gW(){return!hW.isActive}function _W(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}function vW(e){var t=e.current,n=e.next;if(t.length!==n.length)return!0;for(var r=0;r<t.length;r++)if(t[r].element!==n[r].element)return!0;return!1}function yW(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=e.dispatchEvent;if(!gW())return;var a=xW({event:t,dragType:n,getDropTargetsOver:r});hW.isActive=!0;var o={current:a};bW({event:t,current:a.dropTargets});var s=mW({source:n.payload,dispatchEvent:i,initial:a});function c(e){var t=vW({current:o.current.dropTargets,next:e.dropTargets});o.current=e,t&&s.dragUpdate({current:o.current})}function l(e){var t=dW(e),i=r({target:AU(e.target)?jU({x:t.clientX,y:t.clientY}):e.target,input:t,source:n.payload,current:o.current.dropTargets});i.length&&(e.preventDefault(),bW({event:e,current:i})),c({dropTargets:i,input:t})}function u(){o.current.dropTargets.length&&c({dropTargets:[],input:o.current.input}),s.drop({current:o.current,updatedSourcePayload:null}),d()}function d(){hW.isActive=!1,f()}var f=(0,OU.bindAll)(window,[{type:`dragover`,listener:function(e){l(e),s.drag({current:o.current})}},{type:`dragenter`,listener:l},{type:`dragleave`,listener:function(e){lW({dragLeave:e})&&(c({input:o.current.input,dropTargets:[]}),n.startedFrom===`external`&&u())}},{type:`drop`,listener:function(e){o.current={dropTargets:o.current.dropTargets,input:dW(e)},o.current.dropTargets.length?(e.preventDefault(),bW({event:e,current:o.current.dropTargets}),s.drop({current:o.current,updatedSourcePayload:n.type===`external`?n.getDropPayload(e):null}),d()):u()}},{type:`dragend`,listener:function(e){o.current={dropTargets:o.current.dropTargets,input:dW(e)},u()}}].concat(nW(uW({onDragEnd:u}))),{capture:!0});s.start({nativeSetDragImage:_W(t)})}function bW(e){var t=e.event,n=e.current[0]?.dropEffect;n!=null&&t.dataTransfer&&(t.dataTransfer.dropEffect=n)}function xW(e){var t=e.event,n=e.dragType,r=e.getDropTargetsOver,i=dW(t);return n.startedFrom===`external`?{input:i,dropTargets:[]}:{input:i,dropTargets:r({input:i,source:n.payload,target:t.target,current:[]})}}var SW={canStart:gW,start:yW},CW=new Map;function wW(e){var t=e.typeKey,n=e.mount,r=CW.get(t);if(r)return r.usageCount++,r;var i={typeKey:t,unmount:n(),usageCount:1};return CW.set(t,i),i}function TW(e){var t=wW(e);return function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),CW.delete(e.typeKey))}}function EW(){var e=[...arguments];return function(){e.forEach(function(e){return e()})}}function DW(e,t){var n=t.attribute,r=t.value;return e.setAttribute(n,r),function(){return e.removeAttribute(n)}}function OW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kW(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?OW(Object(n),!0).forEach(function(t){FU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):OW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function AW(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=jW(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
70
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function jW(e,t){if(e){if(typeof e==`string`)return MW(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?MW(e,t):void 0}}function MW(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function NW(e){return e.slice(0).reverse()}function PW(e){var t=e.typeKey,n=e.defaultDropEffect,r=new WeakMap,i=`data-drop-target-for-${t}`,a=`[${i}]`;function o(e){return r.set(e.element,e),function(){return r.delete(e.element)}}function s(e){return RU(EW(DW(e.element,{attribute:i,value:`true`}),o(e)))}function c(e){var t=e.source,i=e.target,o=e.input,s=e.result,l=s===void 0?[]:s;if(i==null)return l;if(!(i instanceof Element))return i instanceof Node?c({source:t,target:i.parentElement,input:o,result:l}):l;var u=i.closest(a);if(u==null)return l;var d=r.get(u);if(d==null)return l;var f={input:o,source:t,element:d.element};if(d.canDrop&&!d.canDrop(f))return c({source:t,target:d.element.parentElement,input:o,result:l});var p=d.getData?.call(d,f)??{},m=d.getDropEffect?.call(d,f)??n,h={data:p,element:d.element,dropEffect:m,isActiveDueToStickiness:!1};return c({source:t,target:d.element.parentElement,input:o,result:[].concat(nW(l),[h])})}function l(e){var t=e.eventName,n=e.payload,i=AW(n.location.current.dropTargets),a;try{for(i.s();!(a=i.n()).done;){var o,s=a.value,c=r.get(s.element),l=kW(kW({},n),{},{self:s});c==null||(o=c[t])==null||o.call(c,l)}}catch(e){i.e(e)}finally{i.f()}}var u={onGenerateDragPreview:l,onDrag:l,onDragStart:l,onDrop:l,onDropTargetChange:function(e){var t=e.payload,n=new Set(t.location.current.dropTargets.map(function(e){return e.element})),i=new Set,a=AW(t.location.previous.dropTargets),o;try{for(a.s();!(o=a.n()).done;){var s,c=o.value;i.add(c.element);var l=r.get(c.element),u=n.has(c.element),d=kW(kW({},t),{},{self:c});if(l==null||(s=l.onDropTargetChange)==null||s.call(l,d),!u){var f;l==null||(f=l.onDragLeave)==null||f.call(l,d)}}}catch(e){a.e(e)}finally{a.f()}var p=AW(t.location.current.dropTargets),m;try{for(p.s();!(m=p.n()).done;){var h,g,_=m.value;if(!i.has(_.element)){var v=kW(kW({},t),{},{self:_}),y=r.get(_.element);y==null||(h=y.onDropTargetChange)==null||h.call(y,v),y==null||(g=y.onDragEnter)==null||g.call(y,v)}}}catch(e){p.e(e)}finally{p.f()}}};function d(e){u[e.eventName](e)}function f(e){var t=e.source,n=e.target,i=e.input,a=e.current,o=c({source:t,target:n,input:i});if(o.length>=a.length)return o;for(var s=NW(a),l=NW(o),u=[],d=0;d<s.length;d++){var f,p=s[d],m=l[d];if(m!=null)u.push(m);else{var h=u[d-1],g=s[d-1];if(h?.element!==g?.element)break;var _=r.get(p.element);if(!_)break;var v={input:i,source:t,element:_.element};if(_.canDrop&&!_.canDrop(v)||!((f=_.getIsSticky)!=null&&f.call(_,v)))break;u.push(kW(kW({},p),{},{isActiveDueToStickiness:!0}))}}return NW(u)}return{dropTargetForConsumers:s,getIsOver:f,dispatchEvent:d}}function FW(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=IW(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
71
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function IW(e,t){if(e){if(typeof e==`string`)return LW(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?LW(e,t):void 0}}function LW(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function RW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zW(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?RW(Object(n),!0).forEach(function(t){FU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):RW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function BW(){var e=new Set,t=null;function n(e){t&&(!e.canMonitor||e.canMonitor(t.canMonitorArgs))&&t.active.add(e)}function r(r){var i=zW({},r);e.add(i),n(i);function a(){e.delete(i),t&&t.active.delete(i)}return RU(a)}function i(r){var i=r.eventName,a=r.payload;if(i===`onGenerateDragPreview`){t={canMonitorArgs:{initial:a.location.initial,source:a.source},active:new Set};var o=FW(e),s;try{for(o.s();!(s=o.n()).done;){var c=s.value;n(c)}}catch(e){o.e(e)}finally{o.f()}}if(t){for(var l=Array.from(t.active),u=0,d=l;u<d.length;u++){var f=d[u];if(t.active.has(f)){var p;(p=f[i])==null||p.call(f,a)}}i===`onDrop`&&(t.active.clear(),t=null)}}return{dispatchEvent:i,monitorForConsumers:r}}function VW(e){var t=e.typeKey,n=e.mount,r=e.dispatchEventToSource,i=e.onPostDispatch,a=e.defaultDropEffect,o=BW(),s=PW({typeKey:t,defaultDropEffect:a});function c(e){r?.(e),s.dispatchEvent(e),o.dispatchEvent(e),i?.(e)}function l(e){var t=e.event,n=e.dragType;SW.start({event:t,dragType:n,getDropTargetsOver:s.getIsOver,dispatchEvent:c})}function u(){function e(){return n({canStart:SW.canStart,start:l})}return TW({typeKey:t,mount:e})}return{registerUsage:u,dropTarget:s.dropTargetForConsumers,monitor:o.monitorForConsumers}}var HW=RU(function(){return navigator.userAgent.toLocaleLowerCase().includes(`android`)}),UW=`pdnd:android-fallback`,WW=`text/plain`,GW=`application/vnd.pdnd`,KW=new WeakMap;function qW(e){return KW.set(e.element,e),function(){KW.delete(e.element)}}var JW=QU(),YW=VW({typeKey:`element`,defaultDropEffect:`move`,mount:function(e){return EW(JW.bindEvents(),(0,OU.bind)(document,{type:`dragstart`,listener:function(t){if(e.canStart(t)&&!t.defaultPrevented&&t.dataTransfer){var n=t.target;if(n instanceof HTMLElement){var r=KW.get(n);if(r){var i=dW(t),a={element:r.element,dragHandle:r.dragHandle??null,input:i};if(r.canDrag&&!r.canDrag(a))t.preventDefault();else{if(r.dragHandle){var o=jU({x:i.clientX,y:i.clientY});if(!r.dragHandle.contains(o)){t.preventDefault();return}}var s=r.getInitialDataForExternal?.call(r,a)??null;if(s)for(var c=0,l=Object.entries(s);c<l.length;c++){var u=TU(l[c],2),d=u[0],f=u[1];t.dataTransfer.setData(d,f??``)}HW()&&!t.dataTransfer.types.includes(`text/plain`)&&!t.dataTransfer.types.includes(`text/uri-list`)&&t.dataTransfer.setData(WW,UW),t.dataTransfer.setData(GW,``);var p={type:`element`,payload:{element:r.element,dragHandle:r.dragHandle??null,data:r.getInitialData?.call(r,a)??{}},startedFrom:`internal`};e.start({event:t,dragType:p})}}}}}}))},dispatchEventToSource:function(e){var t,n,r=e.eventName,i=e.payload;(t=KW.get(i.source.element))==null||(n=t[r])==null||n.call(t,i)},onPostDispatch:JW.getOnPostDispatch()}),XW=YW.dropTarget,ZW=YW.monitor;function QW(e){return RU(EW(YW.registerUsage(),qW(e),DW(e.element,{attribute:`draggable`,value:`true`})))}function $W(e){return e[eG]??null}var eG=Symbol(`closestEdge`);function tG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nG(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?tG(Object(n),!0).forEach(function(t){FU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tG(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var rG={top:function(e,t){return Math.abs(t.y-e.top)},right:function(e,t){return Math.abs(e.right-t.x)},bottom:function(e,t){return Math.abs(e.bottom-t.y)},left:function(e,t){return Math.abs(t.x-e.left)}};function iG(e,t){var n=t.element,r=t.input,i=t.allowedEdges,a={x:r.clientX,y:r.clientY},o=n.getBoundingClientRect(),s=i.map(function(e){return{edge:e,value:rG[e](o,a)}}).sort(function(e,t){return e.value-t.value})[0]?.edge??null;return nG(nG({},e),{},FU({},eG,s))}function aG(e){var t=e.startIndex,n=e.closestEdgeOfTarget,r=e.indexOfTarget,i=e.axis;if(t===-1||r===-1||t===r)return t;if(n==null)return r;var a=i===`vertical`&&n===`bottom`||i===`horizontal`&&n===`right`;return t<r?a?r:r-1:a?r+1:r}function oG(e,t){return e.list===t&&typeof e.index==`number`}function sG(e,{list:t,index:n,enabled:r}){let[i,a]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let i=e.current;if(!i||!r)return;let o={list:t,index:n};return EW(QW({element:i,getInitialData:()=>o}),XW({element:i,canDrop:({source:e})=>oG(e.data,t),getData:({input:e})=>iG(o,{element:i,input:e,allowedEdges:[`top`,`bottom`]}),onDrag:({self:e,source:t})=>{let r=$W(e.data),i=t.data.index,o=i===n||r===`top`&&i===n-1||r===`bottom`&&i===n+1;a(o?null:r)},onDragLeave:()=>a(null),onDrop:()=>a(null)}))},[e,t,n,r]),i}function cG(e,t){(0,y.useEffect)(()=>ZW({canMonitor:({source:t})=>oG(t.data,e),onDrop:({source:n,location:r})=>{let i=r.current.dropTargets[0];if(!i||!oG(i.data,e))return;let a=n.data.index,o=aG({startIndex:a,indexOfTarget:i.data.index,closestEdgeOfTarget:$W(i.data),axis:`vertical`});o!==a&&t(a,o)}}),[e,t])}function lG({id:e,title:t,children:n}){return(0,G.jsxs)(`div`,{className:`flex h-[29px] items-center justify-between px-3 pt-1.5 text-label text-muted-foreground`,children:[(0,G.jsx)(`h2`,{id:e,children:t}),n]})}var uG=`layers`;function dG({frames:e,calls:t=WE}){let[n,r]=(0,y.useState)(new Set),i=xD(e=>e.page),a=xD(e=>e.frames),o=xD(e=>e.element??null),s=Z(e=>e.canWrite);vG(r);let c=[...e].reverse();cG(uG,(0,y.useCallback)((n,r)=>{let i=[...e].reverse(),a=i[n];a&&t.orderFrame(a.ref,i.length-1-r).catch(ZE(`Couldn't move ${a.name}`))},[e,t]));let l=e=>n.has(e),u=e=>r(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,G.jsxs)(`section`,{"aria-labelledby":`layers-heading`,className:`flex min-h-0 flex-col`,children:[(0,G.jsx)(lG,{id:`layers-heading`,title:`Layers`,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":`Collapse all layers`,title:`Collapse all layers`,onClick:()=>r(new Set),className:`grid size-5 place-items-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:(0,G.jsx)(tn,{"aria-hidden":!0,className:`size-[15px]`})})}),e.length===0?(0,G.jsx)(`p`,{className:`px-3.5 py-1 text-faint`,children:`No frames on this page`}):(0,G.jsx)(`ul`,{className:`flex min-h-0 flex-col overflow-y-auto pb-1`,children:c.map((e,n)=>{let r=l(e.ref),c=o?.frame===e.ref,d=!c&&i===_G(e)&&a.includes(e.ref);return(0,G.jsx)(hG,{frame:e,index:n,canWrite:s,calls:t,tint:d?`bg-primary/26`:c?`bg-primary/7`:void 0,chevron:(0,G.jsx)(`button`,{type:`button`,"aria-label":`${r?`Hide`:`Show`} the elements of ${e.name}`,"aria-expanded":r,onClick:()=>u(e.ref),className:`grid w-2.5 shrink-0 place-items-center text-faint outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,children:r?(0,G.jsx)(dt,{"aria-hidden":!0,className:`size-2.5`}):(0,G.jsx)(pt,{"aria-hidden":!0,className:`size-2.5`})}),children:r?(0,G.jsx)(_U,{frame:e,page:_G(e),selected:c?o?.index??null:null,frameSelected:d,isOpen:t=>l(gG(e.ref,t)),toggle:t=>u(gG(e.ref,t))}):null},e.ref)})})]})}var fG=`grid size-5 shrink-0 place-items-center rounded-[5px] outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none`,pG=`opacity-0 group-hover:opacity-100 group-focus-within:opacity-100`,mG={hidden:[`show`,`hide`],locked:[`unlock`,`lock`]};function hG({frame:e,index:t,canWrite:n,calls:r,tint:i,chevron:a,children:o}){let s=(0,y.useRef)(null),c=WF(`layers`)===e.ref,l=Z(t=>t.claims[e.ref]),u=jN(t=>e.ref in t.unseen),d=sG(s,{list:uG,index:t,enabled:n&&!c}),f=t=>{e.hidden||iD.getState().mode!==`edit`||(t.shiftKey?lD(bD,_G(e),e.ref):sD(bD,_G(e),[e.ref]))},p=(t,n)=>r.flagFrames([e.ref],t,n).catch(ZE(`Couldn't ${mG[t][+!!n]} ${e.name}`)),m=(0,G.jsx)(Xn,{"aria-hidden":!0,className:X(`size-[13px] shrink-0`,e.hidden?`text-faint`:`text-muted-foreground`)});return(0,G.jsxs)(`li`,{ref:s,"aria-label":e.hidden?`${e.name}, hidden`:e.name,className:`relative mx-1.5`,children:[(0,G.jsx)(mU,{edge:d}),(0,G.jsxs)(`div`,{className:`flex flex-col overflow-hidden rounded-md`,children:[(0,G.jsx)(fU,{frame:e,page:_G(e),trigger:(0,G.jsxs)(`div`,{className:X(`group flex h-[26px] items-center gap-1.5 pr-1 pl-2 text-foreground`,e.hidden&&`text-faint`,i??`hover:bg-accent`),children:[a,c?(0,G.jsxs)(G.Fragment,{children:[m,(0,G.jsx)(uH,{name:e.name,label:`Rename frame ${e.name}`,onCommit:t=>{KF(),qF(e,t,r)},onCancel:KF})]}):(0,G.jsxs)(`button`,{type:`button`,"aria-label":`Select ${e.name}`,onClick:f,onDoubleClick:()=>{n&&GF(e.ref,`layers`)},onKeyDown:t=>{t.key===`F2`&&n&&(t.preventDefault(),GF(e.ref,`layers`))},className:`flex h-full min-w-0 flex-1 items-center gap-1.5 rounded-[5px] text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-inset`,children:[m,(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})]}),l?(0,G.jsx)(`span`,{role:`img`,"aria-label":`${l.tag} is editing`,className:`ml-auto size-[7px] shrink-0 rounded-full bg-claim shadow-[0_0_0_3px_color-mix(in_srgb,var(--claim)_25%,transparent)]`}):u?(0,G.jsx)($P,{}):null,(0,G.jsx)(`button`,{type:`button`,"aria-label":`${e.hidden?`Show`:`Hide`} ${e.name}`,"aria-pressed":e.hidden,disabled:!n,onClick:()=>void p(`hidden`,!e.hidden),className:X(fG,e.hidden?`text-faint`:X(`text-muted-foreground`,pG)),children:e.hidden?(0,G.jsx)(jt,{"aria-hidden":!0,className:`size-[13px]`}):(0,G.jsx)(Nt,{"aria-hidden":!0,className:`size-[13px]`})}),(0,G.jsx)(`button`,{type:`button`,"aria-label":`${e.locked?`Unlock`:`Lock`} ${e.name}`,"aria-pressed":e.locked,disabled:!n,onClick:()=>void p(`locked`,!e.locked),className:X(fG,`text-muted-foreground`,!e.locked&&pG),children:e.locked?(0,G.jsx)(un,{"aria-hidden":!0,className:`size-[13px]`}):(0,G.jsx)(cn,{"aria-hidden":!0,className:`size-[13px]`})})]})}),o]})]})}function gG(e,t){return`${e}#${t}`}function _G(e){return`${e.project}/${e.page}`}function vG(e){(0,y.useEffect)(()=>{let t=null,n=()=>{let n=t;if(!n)return;let r=NP(n.frame),i=[n.frame];if(r){t=null;for(let e=RP(r.elements,n.index);typeof e==`number`;e=RP(r.elements,e))i.push(gG(n.frame,e))}e(e=>i.every(t=>e.has(t))?e:new Set([...e,...i]))},r=bD.subscribe((e,r)=>{e.element&&e.element!==r.element&&(t=e.element,n())}),i=MP.store.subscribe(n);return()=>{i(),r()}},[e])}function yG({count:e,className:t}){return e===0?null:(0,G.jsx)(`span`,{role:`img`,"aria-label":`${e} unseen ${e===1?`change`:`changes`}`,"data-unseen-count":!0,className:X(`shrink-0 text-[11px] font-semibold text-claim`,t),children:e})}var bG=[`page.rename`,`page.duplicate`,`page.new`,`page.delete`];function xG({onOpen:e,trigger:t}){let[n,r,i,a]=Ce(bG),o=(0,y.useRef)(null),s=uU(o);return(0,G.jsxs)(ER,{onOpenChange:t=>{t&&e()},onOpenChangeComplete:s.onOpenChangeComplete,children:[(0,G.jsx)(DR,{render:t,onKeyDown:s.onKeyDown}),(0,G.jsxs)(OR,{ref:o,children:[(0,G.jsxs)(kR,{children:[(0,G.jsx)(IR,{children:`Page`}),(0,G.jsx)(PR,{action:n,children:`Rename`}),(0,G.jsx)(PR,{action:r,children:`Duplicate`}),(0,G.jsx)(PR,{action:i,children:`New page below`})]}),(0,G.jsx)(MR,{}),(0,G.jsx)(FR,{action:a})]})]})}var SG=`pages`,CG=`grid size-5 place-items-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:bg-transparent aria-pressed:bg-accent aria-pressed:text-foreground`;function wG({pages:e,current:t,calls:n=WE}){let[,r]=Rr(),i={current:t,navigate:r,calls:n},[a]=Ce([`page.new`]),o=a?Se(a):!1,s=Z(e=>e.canWrite),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(``),f=u.trim().toLowerCase(),p=f?e.filter(e=>e.name.toLowerCase().includes(f)):e;cG(SG,(0,y.useCallback)((t,r)=>{let i=e[t];i&&n.movePage(i.ref,r).catch(ZE(`Couldn't move ${i.name}`))},[e,n]));let m=()=>{l(!1),d(``)};return(0,G.jsxs)(`nav`,{"aria-labelledby":`pages-heading`,className:`flex h-full min-h-0 flex-col`,children:[(0,G.jsx)(lG,{id:`pages-heading`,title:`Pages`,children:(0,G.jsxs)(`span`,{className:`flex gap-0.5`,children:[(0,G.jsx)(fB,{label:`Search pages`,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":`Search pages`,"aria-pressed":c,onClick:()=>c?m():l(!0),className:CG,children:(0,G.jsx)(Kn,{"aria-hidden":!0,className:`size-[13px]`})})}),(0,G.jsx)(fB,{label:a?.label??`Add page`,keys:a?.keys,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":a?.label??`Add page`,"aria-disabled":!o||void 0,onClick:()=>{a&&o&&a.run()},className:CG,children:(0,G.jsx)(Pn,{"aria-hidden":!0,className:`size-[13px]`})})})]})}),c?(0,G.jsxs)(`div`,{className:`mx-2 mb-1.5 flex h-[26px] shrink-0 items-center gap-1.5 rounded-md bg-muted px-2 ring-[1.5px] ring-primary`,children:[(0,G.jsx)(Kn,{"aria-hidden":!0,className:`size-[13px] shrink-0 text-muted-foreground`}),(0,G.jsx)(`input`,{autoFocus:!0,"aria-label":`Search pages`,value:u,spellCheck:!1,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),m())},className:`min-w-0 flex-1 bg-transparent text-foreground outline-none`}),(0,G.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground`,children:`Esc`})]}):null,p.length===0&&f?(0,G.jsxs)(`p`,{className:`px-3.5 py-1 text-faint`,children:[`No page names match `,u.trim()]}):(0,G.jsx)(`ul`,{className:`flex min-h-0 flex-col -mt-1 overflow-y-auto pt-1 pb-0.5`,children:p.map(t=>(0,G.jsx)(EG,{page:t,pages:e,context:i,needle:f,canWrite:s},t.ref))})]})}var TG=`mx-1.5 flex h-[26px] items-center gap-1.5 rounded-md pr-2 pl-2 text-foreground`;function EG({page:e,pages:t,context:n,needle:r,canWrite:i}){let{current:a}=n,o=(0,y.useRef)(null),s=JE()===e.ref,c=jN(t=>wN(t.unseen,e.ref)),l=sG(o,{list:SG,index:e.index,enabled:i&&!r&&!s}),u=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`w-2.5 shrink-0`}),(0,G.jsx)(zt,{"aria-hidden":!0,className:`size-[13px] shrink-0 text-muted-foreground`})]});return(0,G.jsxs)(`li`,{ref:o,className:`relative`,children:[(0,G.jsx)(mU,{edge:l}),s?(0,G.jsxs)(`div`,{className:X(TG,e.name===a&&`bg-accent`),children:[u,(0,G.jsx)(uH,{name:e.name,label:`Rename page ${e.name}`,onCommit:t=>{XE(),$E(e,t,n)},onCancel:XE})]}):(0,G.jsx)(xG,{onOpen:()=>{e.name!==a&&n.navigate(z(e.project,e.name))},trigger:(0,G.jsxs)(Gr,{href:z(e.project,e.name),"aria-current":e.name===a?`page`:void 0,draggable:!1,onDoubleClick:()=>{i&&YE(e.ref)},onKeyDown:r=>{if(i){if(r.key===`F2`)YE(e.ref);else if(r.key===`Delete`||r.key===`Backspace`)eD(e,t,n);else return;r.preventDefault(),r.stopPropagation()}},className:X(TG,`outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset aria-[current=page]:bg-accent`),children:[u,(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:(0,G.jsx)(DG,{name:e.name,needle:r})}),(0,G.jsx)(yG,{count:c}),e.layoutError?(0,G.jsx)(fr,{role:`img`,"aria-label":`Layout does not read`,className:`size-3.5 shrink-0 text-note`,children:(0,G.jsx)(`title`,{children:`Layout does not read`})}):null]})})]})}function DG({name:e,needle:t}){let n=t?e.toLowerCase().indexOf(t):-1;return n<0?e:(0,G.jsxs)(G.Fragment,{children:[e.slice(0,n),(0,G.jsx)(`mark`,{className:`rounded-[2px] bg-primary/30 text-inherit`,children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}var OG=`frameboard.board.pages`,kG=26,AG=64,jG=237,MG=`h-6 rounded-[5px] border-0 text-xs font-medium text-muted-foreground data-active:bg-card data-active:text-foreground data-active:shadow-none data-active:ring-1 data-active:ring-border dark:data-active:bg-card`;function NG({project:e,page:t,theme:n,assets:r,storage:i,calls:a}){let[o]=Ce([`view.hideUi`]),s=qB(e=>e.open),c=Do({id:OG,onlySaveAfterUserInteractions:!0,storage:i}),l=Math.min(Math.max(29+e.pages.length*kG+4,AG),jG),u=e.pages.find(e=>e.name===t)?.frames??[];return(0,G.jsxs)(`aside`,{"aria-label":`Pages and layers`,className:`flex h-full min-w-0 flex-col bg-sidebar text-sidebar-foreground`,children:[(0,G.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-1.5 border-b border-sidebar-border px-2`,children:[(0,G.jsx)(fB,{label:`Home`,side:`bottom`,children:(0,G.jsx)(Gr,{href:`/`,"aria-label":`Home`,className:PG,children:(0,G.jsx)(qt,{"aria-hidden":!0,className:`size-[15px]`})})}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-panel`,title:e.name,children:e.name}),(0,G.jsx)(fB,{label:`Hide UI`,keys:o?.keys,side:`bottom`,children:(0,G.jsx)(`button`,{type:`button`,"aria-label":`Hide UI`,onClick:()=>o?.run(),className:PG,children:(0,G.jsx)(En,{"aria-hidden":!0,className:`size-[15px]`})})})]}),s?(0,G.jsx)(iU,{project:e.name,page:t}):(0,G.jsxs)(HH,{defaultValue:`design`,className:`min-h-0 flex-1 gap-0`,children:[(0,G.jsxs)(WH,{className:`m-2 h-7 w-auto shrink-0 rounded-[7px] p-0.5`,children:[(0,G.jsx)(GH,{value:`design`,className:MG,children:`Design`}),(0,G.jsx)(GH,{value:`theme`,disabled:!n,className:MG,children:`Theme`}),(0,G.jsx)(GH,{value:`assets`,disabled:!r,className:MG,children:`Assets`})]}),(0,G.jsx)(KH,{value:`design`,className:`flex min-h-0 flex-col text-xs`,children:(0,G.jsxs)(al,{id:OG,orientation:`vertical`,defaultLayout:c.defaultLayout,onLayoutChanged:c.onLayoutChanged,children:[(0,G.jsx)(ol,{id:`pages`,defaultSize:l,minSize:AG,children:(0,G.jsx)(wG,{pages:e.pages,current:t,calls:a})}),(0,G.jsx)(sl,{"aria-label":`Resize the pages list`,className:`group cursor-row-resize aria-[orientation=horizontal]:h-[9px] border-t border-sidebar-border bg-transparent after:hidden focus-visible:ring-0 data-[separator=active]:border-t-2 data-[separator=active]:border-primary data-[separator=focus]:border-t-2 data-[separator=focus]:border-primary`,children:(0,G.jsx)(`span`,{"aria-hidden":!0,className:`h-[3px] w-7 rounded-[2px] bg-faint group-data-[separator=active]:bg-primary group-data-[separator=focus]:bg-primary`})}),(0,G.jsx)(ol,{id:`layers`,minSize:AG,children:(0,G.jsx)(dG,{frames:u,calls:a})})]})}),(0,G.jsx)(KH,{value:`theme`,className:`min-h-0 text-xs`,children:n}),(0,G.jsx)(KH,{value:`assets`,className:`min-h-0 text-xs`,children:r})]})]})}var PG=`grid size-[26px] shrink-0 place-items-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,FG=[`color`,`radius`,`font`,`other`],IG=MT({name:eT(),group:zT(FG),light:eT().nullable(),dark:eT().nullable(),sheet:eT()});MT({sheets:AT(MT({path:eT(),kind:zT([`board`,`project`]),error:eT().nullable()})),tokens:AT(IG)});var LG={color:`Color`,radius:`Radius`,font:`Font`,other:`Other`},RG=`font-mono text-label font-normal text-foreground`;function zG({project:e,load:t=aV}){let n=iV(e,t);return n===void 0?null:n===null?(0,G.jsx)(`p`,{className:`m-3 text-muted-foreground`,children:`The tokens did not load. Reload the board to try again.`}):n.sheets.length===0?(0,G.jsx)(BG,{}):(0,G.jsxs)(`div`,{className:`flex flex-col pb-2`,children:[(0,G.jsxs)(`p`,{className:`mx-3 mt-1 mb-2 rounded-lg bg-muted px-2.5 py-2 leading-[1.45] text-muted-foreground`,children:[`From`,` `,n.sheets.map((e,t)=>(0,G.jsxs)(y.Fragment,{children:[t>0?` and `:null,(0,G.jsx)(`code`,{className:RG,children:e.path})]},e.path)),`, read-only. Edit the file or ask the agent.`]}),n.sheets.filter(e=>e.error!==null).map(e=>(0,G.jsxs)(`p`,{role:`alert`,className:`mx-3 mb-2 leading-[1.45] text-destructive`,children:[(0,G.jsx)(`code`,{className:RG,children:e.path}),` does not parse, so its tokens are missing here: `,e.error,`. Fix the file or ask the agent.`]},e.path)),n.tokens.length===0?(0,G.jsx)(`p`,{className:`mx-3 text-muted-foreground`,children:`These sheets set no tokens under :root, [data-theme], or .dark.`}):null,FG.map(e=>{let t=n.tokens.filter(t=>t.group===e);return t.length===0?null:(0,G.jsxs)(`section`,{"aria-labelledby":`tokens-${e}`,children:[(0,G.jsx)(`h3`,{id:`tokens-${e}`,className:`px-3 pt-2.5 pb-1 text-label text-muted-foreground`,children:LG[e]}),e===`color`?(0,G.jsx)(VG,{}):null,(0,G.jsx)(`ul`,{children:t.map(t=>e===`color`?(0,G.jsx)(HG,{row:t},t.name):(0,G.jsx)(UG,{row:t},t.name))})]},e)})]})}function BG(){return(0,G.jsxs)(`div`,{className:`m-3 rounded-[10px] border border-dashed border-border p-4 leading-normal text-muted-foreground`,children:[(0,G.jsx)(`p`,{className:`mb-1 font-semibold text-foreground`,children:`No tokens yet`}),`Frames render unstyled until a token sheet exists. Add one at`,` `,(0,G.jsx)(`code`,{className:RG,children:`tokens.css`}),` in this project, or in the board folder for every project.`]})}function VG(){return(0,G.jsxs)(`div`,{"aria-hidden":!0,className:`grid grid-cols-[1fr_18px_18px] gap-1.5 px-3 py-1 text-center text-[10px] text-faint`,children:[(0,G.jsx)(`span`,{}),(0,G.jsx)(`span`,{children:`L`}),(0,G.jsx)(`span`,{children:`D`})]})}function HG({row:e}){return(0,G.jsxs)(`li`,{className:`mx-1.5 grid h-7 grid-cols-[1fr_18px_18px] items-center gap-1.5 rounded-md px-1.5`,children:[(0,G.jsx)(WG,{name:e.name}),(0,G.jsx)(GG,{theme:`Light`,value:e.light}),(0,G.jsx)(GG,{theme:`Dark`,value:e.dark})]})}function UG({row:e}){let t=KG(e);return(0,G.jsxs)(`li`,{className:`mx-1.5 grid h-7 grid-cols-[1fr_auto] items-center gap-1.5 rounded-md px-1.5`,children:[(0,G.jsx)(WG,{name:e.name}),(0,G.jsx)(`span`,{className:`max-w-32 truncate text-muted-foreground`,title:t,children:t})]})}function WG({name:e}){return(0,G.jsxs)(`span`,{className:`truncate`,title:e,children:[(0,G.jsx)(`span`,{className:`text-faint`,children:`--`}),e.replace(/^--/,``)]})}function GG({theme:e,value:t}){return t===null?(0,G.jsx)(`span`,{role:`img`,"aria-label":`${e}: not set`,title:`Not set in ${e.toLowerCase()}`,className:`size-4 rounded-[4px] border border-dashed border-faint`}):(0,G.jsx)(`span`,{role:`img`,"aria-label":`${e}: ${t}`,title:t,className:`size-4 rounded-[4px] shadow-[inset_0_0_0_1px_rgba(127,127,127,.35)]`,style:{background:t}})}function KG(e){let t=e.light??e.dark??``;return e.group===`font`?t.split(`,`)[0]?.trim().replace(/^["']|["']$/g,``)??t:t}var qG={defaultSize:240,minSize:200,maxSize:400},JG=[],YG=`frameboard.board.panels`;function XG({project:e,page:t}){let n=Z(t=>t.board?.projects.find(t=>t.name===e)),r=Z(e=>e.reloads),i=Z(e=>e.findings),a=Z(e=>e.claims),o=Z(e=>e.focus),s=(0,y.useCallback)(()=>yl.setState({focus:null}),[]),c=aD(e=>e.hideUi),l=aD(e=>e.mode===`play`),u=Do({id:YG,panelIds:c?[`canvas`]:[`left`,`canvas`,`right`],onlySaveAfterUserInteractions:!0,storage:QG}),d=n?.pages.find(e=>e.name===t);if(RD(),tD(e,t),YF(d?.ref??``,d?.frames??JG),iI(),Az(),XB(),!n)return(0,G.jsx)(ZG,{message:`No project ${e} on this board.`});let f=n.pages[0];return t===void 0&&f?(0,G.jsx)(Jr,{to:z(e,f.name),replace:!0}):(0,G.jsxs)(al,{id:`board`,className:`text-body`,defaultLayout:u.defaultLayout,onLayoutChanged:u.onLayoutChanged,children:[c?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ol,{id:`left`,...qG,groupResizeBehavior:`preserve-pixel-size`,children:(0,G.jsx)(NG,{project:n,page:t??``,theme:(0,G.jsx)(zG,{project:n.name}),assets:(0,G.jsx)(Fl,{project:n.name}),storage:QG})}),(0,G.jsx)(sl,{"aria-label":`Resize the left panel`})]}),(0,G.jsx)(ol,{id:`canvas`,children:(0,G.jsxs)(`main`,{className:`relative size-full min-w-0`,children:[d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Sz,{page:d,reloads:r,findings:i,claims:a,focus:o,onFocused:s},d.ref),(0,G.jsx)(BB,{}),(0,G.jsx)(Iz,{})]}):(0,G.jsx)(ZG,{message:f?`No page ${t} in ${e}.`:`${e} has no pages yet. An agent adds one with frameboard page add <name>.`}),l?(0,G.jsx)(IB,{}):null,c?(0,G.jsx)(FB,{project:n.name}):null]})}),c?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(sl,{"aria-label":`Resize the inspector`}),(0,G.jsx)(ol,{id:`right`,...qG,groupResizeBehavior:`preserve-pixel-size`,children:(0,G.jsx)(gH,{})})]})]})}function ZG({message:e}){return(0,G.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,G.jsx)(`p`,{className:`text-body text-muted-foreground`,children:e}),(0,G.jsx)(Gr,{href:`/`,className:rl({variant:`outline`}),children:`Go home`})]})}var QG={getItem:e=>{try{return localStorage.getItem(e)}catch{return null}},setItem:(e,t)=>{try{localStorage.setItem(e,t)}catch{}}},$G=[`home.layoutGrid`,`home.layoutList`,`project.new`,`theme.toggle`];function eK({hasProjects:e}){let[t,n,r,i]=Ce($G);return(0,G.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-3 border-b border-border bg-card px-4 sm:px-6`,children:[(0,G.jsxs)(`span`,{className:`flex flex-1 items-center gap-2 text-sm font-semibold`,children:[(0,G.jsx)(iK,{}),`Frameboard`]}),e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{role:`group`,"aria-label":`Layout`,className:`flex rounded-lg bg-muted p-0.5`,children:[(0,G.jsx)(nK,{action:t,label:`Grid`,children:(0,G.jsx)(Zt,{"aria-hidden":!0,className:`size-3.5`})}),(0,G.jsx)(nK,{action:n,label:`List`,children:(0,G.jsx)(rn,{"aria-hidden":!0,className:`size-3.5`})})]}),(0,G.jsx)(tK,{action:r,compact:!0})]}):null,(0,G.jsxs)(`button`,{type:`button`,"aria-label":i?.label??`Theme`,title:i?.label??`Theme`,...rK(i),className:`grid size-[26px] place-items-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:bg-transparent`,children:[(0,G.jsx)(er,{"aria-hidden":!0,className:`size-[15px] dark:hidden`}),(0,G.jsx)(vn,{"aria-hidden":!0,className:`hidden size-[15px] dark:block`})]})]})}function tK({action:e,className:t,compact:n=!1}){return(0,G.jsxs)(`button`,{type:`button`,"aria-label":`New project`,...rK(e),className:X(`flex h-[30px] items-center gap-1.5 rounded-lg bg-primary px-3 font-medium text-primary-foreground outline-none hover:bg-primary/90 focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:bg-primary`,t),children:[(0,G.jsx)(Pn,{"aria-hidden":!0,className:`size-3.5`}),(0,G.jsx)(`span`,{className:X(`whitespace-nowrap`,n&&`hidden sm:inline`),children:`New project`})]})}function nK({action:e,label:t,children:n}){let r=e?.checked?.()??!1;return(0,G.jsx)(`button`,{type:`button`,"aria-label":t,title:t,"aria-pressed":r,...rK(e),className:X(`grid h-[26px] w-7 place-items-center rounded-md text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50`,r&&`bg-card text-foreground ring-1 ring-border`),children:n})}function rK(e){let t=e?Se(e):!1;return{"aria-disabled":!t||void 0,onClick:()=>{e&&t&&e.run()}}}function iK(){return(0,G.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 64 64`,className:`size-5`,children:[(0,G.jsx)(`rect`,{x:`4`,y:`12`,width:`48`,height:`48`,rx:`12`,className:`fill-primary`}),(0,G.jsx)(`rect`,{x:`34`,y:`4`,width:`26`,height:`26`,rx:`7`,strokeWidth:`4`,className:`fill-foreground stroke-card`})]})}function aK(){let[e]=Ce([`project.new`]);return(0,G.jsx)(`div`,{className:`relative flex-1`,children:(0,G.jsxs)(`div`,{className:`absolute top-1/2 left-1/2 w-105 max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-[55%] text-center leading-[1.6] text-muted-foreground`,children:[(0,G.jsx)(`div`,{"aria-hidden":!0,className:`mx-auto mb-3.5 h-12 w-16 rounded-lg border-[1.5px] border-dashed border-faint`}),(0,G.jsx)(`h1`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`No projects yet`}),(0,G.jsx)(`p`,{children:`A project holds the pages and frames for one thing you are designing.`}),(0,G.jsx)(tK,{action:e,className:`mx-auto mt-3.5 mb-2.5`}),(0,G.jsxs)(`p`,{children:[`or from a terminal`,` `,(0,G.jsx)(`code`,{className:`rounded-[5px] bg-muted px-1.5 py-0.5 font-mono text-label font-normal text-foreground`,children:`frameboard project add <name>`})]})]})})}var oK=`frameboard.home.layout`;function sK(){let[e,t]=(0,y.useState)(cK),n=(0,y.useRef)(e);return(0,y.useEffect)(()=>{let e=e=>{n.current=e,t(e),lK(e),xe()};return be([{id:`home.layoutGrid`,label:`Grid`,group:`home`,command:{label:`Show projects as a grid`,icon:Zt},run:()=>e(`grid`),checked:()=>n.current===`grid`},{id:`home.layoutList`,label:`List`,group:`home`,command:{label:`Show projects as a list`,icon:rn},run:()=>e(`list`),checked:()=>n.current===`list`}])},[]),e}function cK(){try{return localStorage.getItem(oK)===`list`?`list`:`grid`}catch{return`grid`}}function lK(e){try{localStorage.setItem(oK,e)}catch{}}var uK=ue()(()=>({focused:null,renaming:null}));function dK(e){return fe(uK,t=>t.renaming?.project===e?t.renaming:null)}function fK(e){uK.getState().focused!==e&&(uK.setState({focused:e}),xe())}function pK(e){uK.setState({renaming:{project:e,draft:e,refusal:null,attempt:0}})}function mK(){uK.setState({renaming:null})}function hK({name:e,pages:t}){let n=t[0];return n?z(e,n.name):`/p/${encodeURIComponent(e)}`}async function gK(e,t,n=WE){uK.setState(({renaming:e})=>({renaming:e&&{...e,draft:t}}));try{await n.renameProject(e,t)}catch(t){if(t instanceof jl&&t.code===`invalid-name`){uK.setState(({renaming:e})=>({renaming:e&&{...e,refusal:t.message,attempt:e.attempt+1}}));return}mK(),ZE(`Couldn't rename ${e}`)(t);return}mK(),fK(t)}function _K(e=WE){let[,t]=Rr();(0,y.useEffect)(()=>{let n=()=>yl.getState().canWrite,r=()=>{let e=uK.getState().focused;return yl.getState().board?.projects.find(t=>t.name===e)},i=()=>n()&&r()!==void 0,a=be([{id:`project.new`,label:`New project`,group:`project`,command:{label:`New project`,icon:Vt},enabled:n,run:()=>{e.addProject().then(e=>{fK(e.name),pK(e.name)},ZE(`Couldn't add a project`))}},{id:`project.open`,label:`Open`,group:`project`,enabled:()=>r()!==void 0,run:()=>{let e=r();e&&t(hK(e))}},{id:`project.rename`,label:`Rename`,group:`project`,enabled:i,run:()=>{let e=r();e&&pK(e.name)}},{id:`project.duplicate`,label:`Duplicate`,group:`project`,enabled:i,run:()=>{let t=r();t&&e.duplicateProject(t.name).then(e=>fK(e.name),ZE(`Couldn't duplicate ${t.name}`))}},{id:`project.delete`,label:`Delete`,group:`project`,enabled:i,run:()=>{let t=r();t&&e.deleteProject(t.name).catch(ZE(`Couldn't delete ${t.name}`))}}]),o=yl.subscribe((e,t)=>{(e.canWrite!==t.canWrite||e.board!==t.board)&&xe()});return()=>{o(),a(),uK.setState({focused:null,renaming:null})}},[e,t])}var vK=[`project.open`,`project.rename`,`project.duplicate`,`project.delete`];function yK({project:e,trigger:t}){let[n,r,i,a]=Ce(vK),o=(0,y.useRef)(null),s=uU(o);return(0,G.jsxs)(ER,{onOpenChange:t=>{t&&fK(e)},onOpenChangeComplete:s.onOpenChangeComplete,children:[(0,G.jsx)(DR,{render:t,onKeyDown:s.onKeyDown}),(0,G.jsxs)(OR,{ref:o,children:[(0,G.jsxs)(kR,{children:[(0,G.jsx)(AR,{children:`Project`}),(0,G.jsx)(bK,{action:n,keyHint:`↵`,keyName:`Enter`,children:`Open`}),(0,G.jsx)(bK,{action:r,children:`Rename`}),(0,G.jsx)(bK,{action:i,children:`Duplicate`})]}),(0,G.jsx)(MR,{}),(0,G.jsx)(bK,{action:a,keyHint:`⌫`,keyName:`Delete`,variant:`destructive`,children:`Delete`})]})]})}function bK({action:e,children:t,keyHint:n,keyName:r,variant:i}){return(0,G.jsxs)(jR,{variant:i,disabled:!e||!Se(e),"aria-keyshortcuts":r,onClick:()=>e?.run(),children:[t,n?(0,G.jsx)(NR,{"aria-hidden":!0,children:n}):null]})}function xK({project:e,captures:t,className:n}){let r=(e.pages[0]?.frames??[]).filter(e=>!e.hidden);if(r.length===0)return null;let i=r.map(e=>e.box),a=Math.min(...i.map(e=>e.x)),o=Math.min(...i.map(e=>e.y)),s=Math.max(...i.map(e=>e.x+e.width)),c=Math.max(...i.map(e=>e.y+e.height));return(0,G.jsx)(`svg`,{"aria-hidden":!0,"data-skeleton":!0,viewBox:`${a} ${o} ${s-a} ${c-o}`,preserveAspectRatio:`xMidYMin meet`,className:n,children:r.map(({ref:e,box:n})=>{let r=t?.stamps[e];return(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`rect`,{x:n.x,y:n.y,width:n.width,height:n.height,className:`fill-white stroke-black/6`,strokeWidth:1,vectorEffect:`non-scaling-stroke`}),t&&r?(0,G.jsx)(`image`,{href:SK(e,t.theme,r),x:n.x,y:n.y,width:n.width,height:n.height,preserveAspectRatio:`none`}):null]},e)})})}function SK(e,t,n){return`/api/thumbnails/png?${new URLSearchParams({ref:e,theme:t,v:n})}`}function CK({projects:e,layout:t,now:n,calls:r}){let i=jN(e=>e.unseen),a=tv(),o={theme:a,stamps:Z(e=>e.thumbnails[a])};return(0,G.jsxs)(`main`,{className:`px-4 py-8 sm:px-12`,children:[(0,G.jsx)(`h1`,{className:`mb-5 text-title`,children:`Projects`}),t===`grid`?(0,G.jsx)(`ul`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-5`,children:e.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(wK,{project:e,className:`block overflow-hidden rounded-xl border border-border bg-card text-card-foreground outline-none hover:ring-2 hover:ring-primary focus-visible:ring-2 focus-visible:ring-primary data-popup-open:ring-2 data-popup-open:ring-primary`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`m-1.5 block h-[150px] overflow-hidden rounded-lg bg-background p-3.5`,children:(0,G.jsx)(xK,{project:e,captures:o,className:`size-full`})}),(0,G.jsxs)(`span`,{className:`flex flex-col px-3 pt-1.5 pb-3`,children:[(0,G.jsx)(EK,{project:e,calls:r,type:`text-panel`,unseen:wN(i,e.name)}),(0,G.jsx)(OK,{project:e,now:n,prefix:`Edited `})]})]})},e.name))}):(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-card text-card-foreground`,children:[(0,G.jsxs)(`div`,{"aria-hidden":!0,className:`grid h-9 grid-cols-[48px_1fr] sm:grid-cols-[48px_1fr_160px_160px] items-center border-b border-border px-4 text-label text-muted-foreground`,children:[(0,G.jsx)(`span`,{}),(0,G.jsx)(`span`,{children:`Name`}),(0,G.jsx)(`span`,{className:`hidden sm:block`,children:`Edited`}),(0,G.jsx)(`span`,{className:`hidden sm:block`,children:`Created`})]}),(0,G.jsx)(`ul`,{children:e.map(e=>(0,G.jsx)(`li`,{className:`not-last:border-b`,children:(0,G.jsxs)(wK,{project:e,className:`grid h-12 grid-cols-[48px_1fr] sm:grid-cols-[48px_1fr_160px_160px] items-center px-4 outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset data-popup-open:ring-2 data-popup-open:ring-primary data-popup-open:ring-inset`,children:[(0,G.jsx)(DK,{project:e}),(0,G.jsx)(EK,{project:e,calls:r,type:`font-medium`,unseen:wN(i,e.name),className:`pr-4`}),(0,G.jsx)(`span`,{className:`hidden truncate sm:block`,children:(0,G.jsx)(OK,{project:e,now:n,prefix:``})}),(0,G.jsx)(`span`,{className:`hidden sm:block`,children:(0,G.jsx)(kK,{project:e})})]})},e.name))})]})]})}function wK({project:e,className:t,children:n}){return dK(e.name)===null?(0,G.jsx)(yK,{project:e.name,trigger:(0,G.jsx)(Gr,{href:hK(e),onFocus:()=>fK(e.name),onKeyDown:t=>{let n=TK[t.key];if(!n)return;fK(e.name);let r=we(n);r&&Se(r)&&r.run(),t.preventDefault()},className:t,children:n})}):(0,G.jsx)(`div`,{className:t,children:n})}var TK={F2:`project.rename`,Delete:`project.delete`,Backspace:`project.delete`};function EK({project:e,calls:t,type:n,unseen:r,className:i}){let a=dK(e.name);return a?(0,G.jsxs)(`span`,{className:X(`flex min-w-0 flex-col`,n),children:[(0,G.jsx)(`span`,{className:`flex h-lh items-center pl-1.5`,children:(0,G.jsx)(uH,{name:a.draft,label:`Rename project ${e.name}`,onCommit:n=>void gK(e.name,n,t),onCancel:mK},a.attempt)}),a.refusal?(0,G.jsx)(`span`,{role:`alert`,className:`mt-1 text-label font-normal text-destructive`,children:a.refusal}):null]}):(0,G.jsxs)(`span`,{className:X(`flex min-w-0 items-center gap-1.5`,i),children:[(0,G.jsx)(`span`,{className:X(`truncate`,n),title:e.name,children:e.name}),(0,G.jsx)(yG,{count:r,className:`ml-auto`})]})}function DK({project:e}){return(0,G.jsx)(`span`,{"aria-hidden":!0,className:`block h-[22px] w-8 overflow-hidden rounded bg-background p-[5px]`,children:(0,G.jsx)(xK,{project:e,className:`size-full`})})}function OK({project:e,now:t,prefix:n}){return(0,G.jsxs)(`span`,{"data-edited":!0,className:`truncate text-body text-muted-foreground`,title:new Date(e.modifiedAt).toLocaleString(),children:[n,jK(Date.parse(e.modifiedAt),t)]})}function kK({project:e}){if(!e.createdAt)return(0,G.jsx)(`span`,{});let t=new Date(e.createdAt);return(0,G.jsx)(`time`,{dateTime:e.createdAt,className:`text-body text-muted-foreground`,title:t.toLocaleString(),children:MK(t)})}var AK=[[`year`,31536e3],[`month`,2592e3],[`week`,604800],[`day`,86400],[`hour`,3600],[`minute`,60]];function jK(e,t){let n=Math.max(0,(t-e)/1e3),r=new Intl.RelativeTimeFormat(`en`,{numeric:`auto`});for(let[e,t]of AK)if(n>=t)return r.format(-Math.floor(n/t),e);return`just now`}function MK(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}var NK=100;function PK(e=fetch){let t=tv(),n=Z(e=>e.connected),r=Z(e=>e.board),i=Z(e=>e.reloads),a=(0,y.useRef)(new Map);(0,y.useEffect)(()=>{a.current=new Map},[t,n]),(0,y.useEffect)(()=>{if(!n||!r)return;let o=new Map(FK(r).map(({ref:e,box:t})=>[e,`${t.width}x${t.height}#${i[e]??0}`]));if(![...o].some(([e,t])=>a.current.get(e)!==t))return;let s=setTimeout(()=>{for(let[e,t]of o)a.current.set(e,t);IK(e,t)},NK);return()=>clearTimeout(s)},[e,t,n,r,i])}function FK(e){return e.projects.flatMap(e=>(e.pages[0]?.frames??[]).filter(e=>!e.hidden))}async function IK(e,t){try{let n=await(await e(`/api/thumbnails?theme=${t}`)).json();n.ok&&n.data&&ml(yl,t,n.data.stamps)}catch{}}function LK({projects:e,calls:t}){let[n]=(0,y.useState)(Date.now),r=sK();return _K(t),PK(),(0,G.jsxs)(`div`,{className:`flex min-h-full flex-col text-body`,children:[(0,G.jsx)(eK,{hasProjects:e.length>0}),e.length===0?(0,G.jsx)(aK,{}):(0,G.jsx)(CK,{projects:e,layout:r,now:n,calls:t})]})}var RK=1,zK=.9,BK=.8,VK=.17,HK=.1,UK=.999,WK=.9999,GK=.99,KK=/[\\\/_+.#"@\[\(\{&]/,qK=/[\\\/_+.#"@\[\(\{&]/g,JK=/[\s-]/,YK=/[\s-]/g;function XK(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?RK:GK;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=XK(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=RK:KK.test(e.charAt(l-1))?(d*=BK,p=e.slice(i,l-1).match(qK),p&&i>0&&(d*=UK**+p.length)):JK.test(e.charAt(l-1))?(d*=zK,m=e.slice(i,l-1).match(YK),m&&i>0&&(d*=UK**+m.length)):(d*=VK,i>0&&(d*=UK**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=WK)),(d<HK&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=XK(e,t,n,r,l+1,a+2,o),f*HK>d&&(d=f*HK)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function ZK(e){return e.toLowerCase().replace(YK,` `)}function QK(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,XK(e,t,ZK(e),ZK(t),0,0,{})}var $K=Object.defineProperty,eq=(e,t)=>$K(e,`name`,{value:t,configurable:!0}),tq=!!(typeof window<`u`&&window.document&&window.document.createElement);function nq(e,t,{checkForDefaultPrevented:n=!0}={}){return eq(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}eq(nq,`composeEventHandlers`);function rq(e){if(!tq)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}eq(rq,`getOwnerWindow`);function iq(e){if(!tq)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}eq(iq,`getOwnerDocument`);function aq(e,t=!1){let{activeElement:n}=iq(e);if(!n?.nodeName)return null;if(oq(n)&&n.contentDocument)return aq(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=iq(n).getElementById(e);if(t)return t}}return n}eq(aq,`getActiveElement`);function oq(e){return e.tagName===`IFRAME`}eq(oq,`isFrame`);var sq=Object.defineProperty,cq=(e,t)=>sq(e,`name`,{value:t,configurable:!0});function lq(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}cq(lq,`setRef`);function uq(...e){return t=>{let n=!1,r=e.map(e=>{let r=lq(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():lq(e[t],null)}}}}cq(uq,`composeRefs`);function dq(...e){return y.useCallback(uq(...e),e)}cq(dq,`useComposedRefs`);var fq=Object.defineProperty,pq=(e,t)=>fq(e,`name`,{value:t,configurable:!0});function mq(e,t){let n=y.createContext(t);n.displayName=e+`Context`;let r=pq(e=>{let{children:t,...r}=e,i=y.useMemo(()=>r,Object.values(r));return(0,G.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=y.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return pq(i,`useContext`),[r,i]}pq(mq,`createContext`);function hq(e,t=[]){let n=[];function r(t,r){let i=y.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=pq(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=y.useMemo(()=>o,Object.values(o));return(0,G.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=y.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return pq(s,`useContext`),[o,s]}pq(r,`createContext`);let i=pq(()=>{let t=n.map(e=>y.createContext(e));return pq(function(n){let r=n?.[e]||t;return y.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,gq(i,...t)]}pq(hq,`createContextScope`);function gq(...e){let t=e[0];if(e.length===1)return t;let n=pq(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return pq(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return y.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}pq(gq,`composeContextScopes`);var _q=globalThis?.document?y.useLayoutEffect:()=>{},vq=Object.defineProperty,yq=(e,t)=>vq(e,`name`,{value:t,configurable:!0}),bq=y.useId||(()=>void 0),xq=0;function Sq(e){let[t,n]=y.useState(bq());return _q(()=>{e||n(e=>e??String(xq++))},[e]),e||(t?`radix-${t}`:``)}yq(Sq,`useId`);var Cq=Object.defineProperty,wq=(e,t)=>Cq(e,`name`,{value:t,configurable:!0}),Tq=y.useEffectEvent,Eq=y.useInsertionEffect;function Dq(e){if(typeof Tq==`function`)return Tq(e);let t=y.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof Eq==`function`?Eq(()=>{t.current=e}):_q(()=>{t.current=e}),y.useMemo(()=>((...e)=>t.current?.(...e)),[])}wq(Dq,`useEffectEvent`);var Oq=Object.defineProperty,kq=(e,t)=>Oq(e,`name`,{value:t,configurable:!0}),Aq=y.useInsertionEffect||_q;function jq({prop:e,defaultProp:t,onChange:n=kq(()=>{},`onChange`),caller:r}){let[i,a,o]=Mq({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,y.useCallback(t=>{if(s){let n=Nq(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}kq(jq,`useControllableState`);function Mq({defaultProp:e,onChange:t}){let[n,r]=y.useState(e),i=y.useRef(n),a=y.useRef(t);return Aq(()=>{a.current=t},[t]),y.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}kq(Mq,`useUncontrolledState`);function Nq(e){return typeof e==`function`}kq(Nq,`isFunction`);var Pq=Symbol(`RADIX:SYNC_STATE`);function Fq(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=Dq(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=y.useReducer((t,n)=>{if(n.type===Pq)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=y.useRef(p);y.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=y.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return y.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:Pq,state:i})},[i,d.state,c]),[h,f]}kq(Fq,`useControllableStateReducer`);var Iq=Object.defineProperty,Lq=(e,t)=>Iq(e,`name`,{value:t,configurable:!0});function Rq(e){let t=y.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];r=Jq(r),y.Children.forEach(r,e=>{if(Wq(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;for(;Kq(n)&&typeof Qq==`function`;)n=Qq(n._payload);a=Vq(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=y.cloneElement(a,void 0,s):!o&&y.Children.count(r)===1&&y.isValidElement(r)&&(a=r);let c=a?Uq(a):void 0,l=dq(n,c);if(!a){if(r||r===0)throw Error(o?Zq(e):Xq(e));return r}let u=Hq(i,a.props??{});return a.type!==y.Fragment&&(u.ref=n?l:c),y.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}Lq(Rq,`createSlot`);var zq=Symbol.for(`radix.slottable`);function Bq(e){let t=Lq(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=zq,t}Lq(Bq,`createSlottable`);var Vq=Lq((e,t)=>`child`in e.props?y.isValidElement(t)?y.cloneElement(t,void 0,e.props.children(t.props.children)):null:y.isValidElement(t)?t:null,`getSlottableElementFromSlottable`);function Hq(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`?n[r]=[i,a].filter(Boolean).join(` `):r===`aria-describedby`&&(n[r]=Yq(a,i))}return{...e,...n}}Lq(Hq,`mergeProps`);function Uq(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Lq(Uq,`getElementRef`);function Wq(e){return y.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===zq}Lq(Wq,`isSlottable`);var Gq=Symbol.for(`react.lazy`);function Kq(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Gq&&`_payload`in e&&qq(e._payload)}Lq(Kq,`isLazyComponent`);function qq(e){return typeof e==`object`&&!!e&&`then`in e}Lq(qq,`isPromiseLike`);function Jq(e){let t=e;for(;Kq(t)&&typeof Qq==`function`;)t=Qq(t._payload);return t}Lq(Jq,`useUnwrappedLazy`);function Yq(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}Lq(Yq,`concatAriaDescribedby`);var Xq=Lq(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),Zq=Lq(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),Qq=y.use,$q=Object.defineProperty,eJ=(e,t)=>$q(e,`name`,{value:t,configurable:!0}),tJ=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Rq(`Primitive.${t}`),r=y.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,G.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function nJ(e,t){e&&Gf.flushSync(()=>e.dispatchEvent(t))}eJ(nJ,`dispatchDiscreteCustomEvent`);var rJ=Object.defineProperty,iJ=(e,t)=>rJ(e,`name`,{value:t,configurable:!0}),aJ=y.useInsertionEffect;function oJ(e){let t=y.useRef(e);return typeof aJ==`function`?aJ(()=>{t.current=e}):_q(()=>{t.current=e}),y.useMemo(()=>((...e)=>t.current?.(...e)),[])}iJ(oJ,`useCallbackRef`);var sJ=Object.defineProperty,cJ=(e,t)=>sJ(e,`name`,{value:t,configurable:!0}),lJ=`dismissableLayer.update`,uJ=`dismissableLayer.pointerDownOutside`,dJ=`dismissableLayer.focusOutside`,fJ,pJ=y.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),mJ=y.forwardRef(cJ(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=y.useContext(pJ),[d,f]=y.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=y.useState({}),h=dq(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,b=d?g.indexOf(d):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,S=b>=v,C=y.useRef(!1),w=_J(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:y.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return S&&!t},[u.branches,S])}),T=vJ(e=>{if(r&&C.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),E=d?b===g.length-1:!1,D=oJ(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return y.useEffect(()=>{if(E)return p.addEventListener(`keydown`,D,{capture:!0}),()=>p.removeEventListener(`keydown`,D,{capture:!0})},[p,E,D]),y.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(fJ=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),yJ(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=fJ))}},[d,p,n,u]),y.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),yJ())},[d,u]),y.useEffect(()=>{let e=cJ(()=>m({}),`handleUpdate`);return document.addEventListener(lJ,e),()=>document.removeEventListener(lJ,e)},[]),(0,G.jsx)(tJ.div,{...l,ref:h,style:{pointerEvents:x?S?`auto`:`none`:void 0,...e.style},onFocusCapture:nq(e.onFocusCapture,T.onFocusCapture),onBlurCapture:nq(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:nq(e.onPointerDownCapture,w.onPointerDownCapture)})},`DismissableLayer`));function hJ(){let e=y.useContext(pJ),[t,n]=y.useState(null);return y.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}cJ(hJ,`useDismissableLayerSurface`);var gJ=cJ(()=>!0,`IS_TRUE`);function _J(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=gJ}=t,s=oJ(e),c=y.useRef(!1),l=y.useRef(!1),u=y.useRef(new Map),d=y.useRef(()=>{});return y.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}cJ(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}cJ(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}cJ(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}cJ(p,`handleInteractionBubble`);let m=cJ(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||bJ(uJ,s,p,{discrete:!0})};if(cJ(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:cJ(()=>c.current=!0,`onPointerDownCapture`)}}cJ(_J,`usePointerDownOutside`);function vJ(e,t=globalThis?.document){let n=oJ(e),r=y.useRef(!1);return y.useEffect(()=>{let e=cJ(e=>{e.target&&!r.current&&bJ(dJ,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:cJ(()=>r.current=!0,`onFocusCapture`),onBlurCapture:cJ(()=>r.current=!1,`onBlurCapture`)}}cJ(vJ,`useFocusOutside`);function yJ(){let e=new CustomEvent(lJ);document.dispatchEvent(e)}cJ(yJ,`dispatchUpdate`);function bJ(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?nJ(i,a):i.dispatchEvent(a)}cJ(bJ,`handleAndDispatchCustomEvent`);var xJ=Object.defineProperty,SJ=(e,t)=>xJ(e,`name`,{value:t,configurable:!0}),CJ=`focusScope.autoFocusOnMount`,wJ=`focusScope.autoFocusOnUnmount`,TJ={bubbles:!1,cancelable:!0},EJ=y.forwardRef(SJ(function(e,t){let{loop:n=!1,trapped:r=!1,branches:i,onMountAutoFocus:a,onUnmountAutoFocus:o,...s}=e,[c,l]=y.useState(null),u=oJ(a),d=oJ(o),f=y.useRef(null),p=dq(t,l),m=y.useRef(i);y.useEffect(()=>{m.current=i});let h=y.useCallback(e=>e?c?.contains(e)?!0:!!m.current?.some(t=>t.contains(e)):!1,[c]),g=y.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;y.useEffect(()=>{if(r){let e=function(e){if(g.paused||!c)return;let t=e.target;h(t)?f.current=t:LJ(f.current,{select:!0})},t=function(e){if(g.paused||!c)return;let t=e.relatedTarget;t!==null&&(h(t)||LJ(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&LJ(c)};SJ(e,`handleFocusIn`),SJ(t,`handleFocusOut`),SJ(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,c,g.paused,h]),y.useEffect(()=>{if(c){RJ.add(g);let e=document.activeElement;if(!c.contains(e)){let t=new CustomEvent(CJ,TJ);c.addEventListener(CJ,u),c.dispatchEvent(t),t.defaultPrevented||(jJ(VJ(NJ(c)),{select:!0}),document.activeElement===e&&LJ(c))}return()=>{c.removeEventListener(CJ,u);let t=c.ownerDocument,n=CustomEvent;setTimeout(()=>{let r=new n(wJ,TJ);c.addEventListener(wJ,d),c.dispatchEvent(r),r.defaultPrevented||LJ(e??t.body,{select:!0}),c.removeEventListener(wJ,d),RJ.remove(g)},0)}}},[c,u,d,g]);let _=y.useCallback(e=>{if(!n&&!r||g.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=MJ(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&LJ(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&LJ(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,g.paused]);return(0,G.jsx)(tJ.div,{tabIndex:-1,...s,ref:p,onKeyDown:_})},`FocusScope`)),DJ=y.createContext(null);function OJ({registry:e,children:t}){return e?(0,G.jsx)(DJ.Provider,{value:e,children:t}):t}SJ(OJ,`FocusScopeBranchProvider`);function kJ(){let[e,t]=y.useState([]);return{nodes:e,registry:y.useMemo(()=>({add:SJ(e=>t(t=>t.includes(e)?t:[...t,e]),`add`),remove:SJ(e=>t(t=>t.filter(t=>t!==e)),`remove`)}),[])}}SJ(kJ,`useFocusScopeBranchRegistry`);function AJ(e){let t=y.useContext(DJ);y.useEffect(()=>{if(e&&t)return t.add(e),()=>t.remove(e)},[e,t])}SJ(AJ,`useFocusScopeBranch`);function jJ(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(LJ(r,{select:t}),document.activeElement!==n)return}SJ(jJ,`focusFirst`);function MJ(e){let t=NJ(e);return[PJ(t,e),PJ(t.reverse(),e)]}SJ(MJ,`getTabbableEdges`);function NJ(e){let t=[],n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:SJ(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}SJ(NJ,`getTabbableCandidates`);function PJ(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):FJ(r,{upTo:t})))return r}SJ(PJ,`findVisible`);function FJ(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}SJ(FJ,`isHidden`);function IJ(e){return e.tagName===`INPUT`&&typeof e.select==`function`}SJ(IJ,`isSelectableInput`);function LJ(e,{select:t=!1}={}){if(e&&e.focus){let n=(e.ownerDocument??document).activeElement;e.focus({preventScroll:!0}),e!==n&&IJ(e)&&t&&e.select()}}SJ(LJ,`focus`);var RJ=zJ();function zJ(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=BJ(e,t),e.unshift(t)},remove(t){e=BJ(e,t),e[0]?.resume()}}}SJ(zJ,`createFocusScopesStack`);function BJ(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}SJ(BJ,`arrayRemove`);function VJ(e){return e.filter(e=>e.tagName!==`A`)}SJ(VJ,`removeLinks`);var HJ=Object.defineProperty,UJ=y.forwardRef(((e,t)=>HJ(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=y.useState(!1);_q(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Gf.createPortal((0,G.jsx)(tJ.div,{...r,ref:t}),o):null},`Portal`)),WJ=Object.defineProperty,GJ=(e,t)=>WJ(e,`name`,{value:t,configurable:!0});function KJ(e,t){return y.useReducer((e,n)=>t[e][n]??e,e)}GJ(KJ,`useStateMachine`);var qJ=GJ(e=>{let{present:t,children:n}=e,r=JJ(t),i=typeof n==`function`?n({present:r.isPresent}):y.Children.only(n),a=XJ(r.ref,QJ(i));return typeof n==`function`||r.isPresent?y.cloneElement(i,{ref:a}):null},`Presence`);function JJ(e){let[t,n]=y.useState(),r=y.useRef(null),i=y.useRef(e),a=y.useRef(`none`),o=y.useRef(void 0),[s,c]=KJ(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return y.useEffect(()=>{s===`mounted`?(a.current=o.current??ZJ(r.current),o.current=void 0):a.current=`none`},[s]),_q(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=ZJ(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),_q(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=GJ(a=>{let o=ZJ(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=GJ(e=>{e.target===t&&(a.current=ZJ(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:y.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=ZJ(t)}else r.current=null;n(e)},[])}}GJ(JJ,`usePresence`);function YJ(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}GJ(YJ,`setRef`);function XJ(...e){let t=y.useRef(e);return t.current=e,y.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=YJ(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():YJ(n[e],null)}}},[])}GJ(XJ,`useStableComposedRefs`);function ZJ(e){return e?.animationName||`none`}GJ(ZJ,`getAnimationName`);function QJ(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}GJ(QJ,`getElementRef`);var $J=Object.defineProperty,eY=(e,t)=>$J(e,`name`,{value:t,configurable:!0}),tY=0,nY=null;function rY(e){return iY(),e.children}eY(rY,`FocusGuards`);function iY(){y.useEffect(()=>{nY||={start:aY(),end:aY()};let{start:e,end:t}=nY;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),tY++,()=>{tY===1&&(nY?.start.remove(),nY?.end.remove(),nY=null),tY=Math.max(0,tY-1)}},[])}eY(iY,`useFocusGuards`);function aY(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}eY(aY,`createFocusGuard`);var oY=function(){return oY=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},oY.apply(this,arguments)};function sY(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function cY(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var lY=`right-scroll-bar-position`,uY=`width-before-scroll-bar`,dY=`with-scroll-bars-hidden`,fY=`--removed-body-scroll-bar-size`;function pY(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function mY(e,t){var n=(0,y.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var hY=typeof window<`u`?y.useLayoutEffect:y.useEffect,gY=new WeakMap;function _Y(e,t){var n=mY(t||null,function(t){return e.forEach(function(e){return pY(e,t)})});return hY(function(){var t=gY.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||pY(e,null)}),i.forEach(function(e){r.has(e)||pY(e,a)})}gY.set(n,e)},[e]),n}function vY(e){return e}function yY(e,t){t===void 0&&(t=vY);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function bY(e){e===void 0&&(e={});var t=yY(null);return t.options=oY({async:!0,ssr:!1},e),t}var xY=function(e){var t=e.sideCar,n=sY(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return y.createElement(r,oY({},n))};xY.isSideCarExport=!0;function SY(e,t){return e.useMedium(t),xY}var CY=bY(),wY=function(){},TY=y.forwardRef(function(e,t){var n=y.useRef(null),r=y.useState({onScrollCapture:wY,onWheelCapture:wY,onTouchMoveCapture:wY}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,b=e.gapMode,x=sY(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=f,C=_Y([n,t]),w=oY(oY({},x),i);return y.createElement(y.Fragment,null,u&&y.createElement(S,{sideCar:CY,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:b}),o?y.cloneElement(y.Children.only(s),oY(oY({},w),{ref:C})):y.createElement(v,oY({},w,{className:c,ref:C}),s))});TY.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},TY.classNames={fullWidth:uY,zeroRight:lY};var EY=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function DY(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=EY();return t&&e.setAttribute(`nonce`,t),e}function OY(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function kY(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var AY=function(){var e=0,t=null;return{add:function(n){e==0&&(t=DY())&&(OY(t,n),kY(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},jY=function(){var e=AY();return function(t,n){y.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},MY=function(){var e=jY();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},NY={left:0,top:0,right:0,gap:0},PY=function(e){return parseInt(e||``,10)||0},FY=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[PY(n),PY(r),PY(i)]},IY=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return NY;var t=FY(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},LY=MY(),RY=`data-scroll-locked`,zY=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
72
+ .${dY} {
73
73
  overflow: hidden ${r};
74
74
  padding-right: ${s}px ${r};
75
75
  }
76
- body[${LY}] {
76
+ body[${RY}] {
77
77
  overflow: hidden ${r};
78
78
  overscroll-behavior: contain;
79
79
  ${[t&&`position: relative ${r};`,n===`margin`&&`
@@ -86,26 +86,26 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
86
86
  `,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
87
87
  }
88
88
 
89
- .${cY} {
89
+ .${lY} {
90
90
  right: ${s}px ${r};
91
91
  }
92
92
 
93
- .${lY} {
93
+ .${uY} {
94
94
  margin-right: ${s}px ${r};
95
95
  }
96
96
 
97
- .${cY} .${cY} {
97
+ .${lY} .${lY} {
98
98
  right: 0 ${r};
99
99
  }
100
100
 
101
- .${lY} .${lY} {
101
+ .${uY} .${uY} {
102
102
  margin-right: 0 ${r};
103
103
  }
104
104
 
105
- body[${LY}] {
106
- ${dY}: ${s}px;
105
+ body[${RY}] {
106
+ ${fY}: ${s}px;
107
107
  }
108
- `},zY=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},BY=function(){y.useEffect(function(){return document.body.setAttribute(LY,(zY()+1).toString()),function(){var e=zY()-1;e<=0?document.body.removeAttribute(LY):document.body.setAttribute(LY,e.toString())}},[])},VY=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;BY();var a=y.useMemo(function(){return FY(i)},[i]);return y.createElement(IY,{styles:RY(a,!t,i,n?``:`!important`)})},HY=!1;if(typeof window<`u`)try{var UY=Object.defineProperty({},"passive",{get:function(){return HY=!0,!0}});window.addEventListener(`test`,UY,UY),window.removeEventListener(`test`,UY,UY)}catch{HY=!1}var WY=HY?{passive:!1}:!1,GY=function(e){return e.tagName===`TEXTAREA`},KY=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!GY(e)&&n[t]===`visible`)},qY=function(e){return KY(e,`overflowY`)},JY=function(e){return KY(e,`overflowX`)},YY=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),QY(e,r)){var i=$Y(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},XY=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},ZY=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},QY=function(e,t){return e===`v`?qY(t):JY(t)},$Y=function(e,t){return e===`v`?XY(t):ZY(t)},eX=function(e,t){return e===`h`&&t===`rtl`?-1:1},tX=function(e,t,n,r,i){var a=eX(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=$Y(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&QY(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},nX=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},rX=function(e){return[e.deltaX,e.deltaY]},iX=function(e){return e&&`current`in e?e.current:e},aX=function(e,t){return e[0]===t[0]&&e[1]===t[1]},oX=function(e){return`
108
+ `},BY=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},VY=function(){y.useEffect(function(){return document.body.setAttribute(RY,(BY()+1).toString()),function(){var e=BY()-1;e<=0?document.body.removeAttribute(RY):document.body.setAttribute(RY,e.toString())}},[])},HY=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;VY();var a=y.useMemo(function(){return IY(i)},[i]);return y.createElement(LY,{styles:zY(a,!t,i,n?``:`!important`)})},UY=!1;if(typeof window<`u`)try{var WY=Object.defineProperty({},"passive",{get:function(){return UY=!0,!0}});window.addEventListener(`test`,WY,WY),window.removeEventListener(`test`,WY,WY)}catch{UY=!1}var GY=UY?{passive:!1}:!1,KY=function(e){return e.tagName===`TEXTAREA`},qY=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!KY(e)&&n[t]===`visible`)},JY=function(e){return qY(e,`overflowY`)},YY=function(e){return qY(e,`overflowX`)},XY=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),$Y(e,r)){var i=eX(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},ZY=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},QY=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},$Y=function(e,t){return e===`v`?JY(t):YY(t)},eX=function(e,t){return e===`v`?ZY(t):QY(t)},tX=function(e,t){return e===`h`&&t===`rtl`?-1:1},nX=function(e,t,n,r,i){var a=tX(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=eX(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&$Y(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},rX=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},iX=function(e){return[e.deltaX,e.deltaY]},aX=function(e){return e&&`current`in e?e.current:e},oX=function(e,t){return e[0]===t[0]&&e[1]===t[1]},sX=function(e){return`
109
109
  .block-interactivity-${e} {pointer-events: none;}
110
110
  .allow-interactivity-${e} {pointer-events: all;}
111
- `},sX=0,cX=[];function lX(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),i=y.useState(sX++)[0],a=y.useState(jY)[0],o=y.useRef(e);y.useEffect(function(){o.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=sY([e.lockRef.current],(e.shards||[]).map(iX),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=y.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=nX(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=YY(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=YY(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return tX(h,t,e,h===`h`?s:c,!0)},[]),c=y.useCallback(function(e){var n=e;if(cX.length&&cX[cX.length-1]===a){var r=`deltaY`in n?rX(n):nX(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&aX(e.delta,r)})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var c=(o.current.shards||[]).map(iX).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=y.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:uX(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=y.useCallback(function(e){n.current=nX(e),r.current=void 0},[]),d=y.useCallback(function(t){l(t.type,rX(t),t.target,s(t,e.lockRef.current))},[]),f=y.useCallback(function(t){l(t.type,nX(t),t.target,s(t,e.lockRef.current))},[]);y.useEffect(function(){return cX.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,WY),document.addEventListener(`touchmove`,c,WY),document.addEventListener(`touchstart`,u,WY),function(){cX=cX.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,WY),document.removeEventListener(`touchmove`,c,WY),document.removeEventListener(`touchstart`,u,WY)}},[]);var p=e.removeScrollBar,m=e.inert;return y.createElement(y.Fragment,null,m?y.createElement(a,{styles:oX(i)}):null,p?y.createElement(VY,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function uX(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var dX=xY(SY,lX),fX=y.forwardRef(function(e,t){return y.createElement(wY,aY({},e,{ref:t,sideCar:dX}))});fX.classNames=wY.classNames;var pX=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},mX=new WeakMap,hX=new WeakMap,gX={},_X=0,vX=function(e){return e&&(e.host||vX(e.parentNode))},yX=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=vX(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},bX=function(e,t,n,r){var i=yX(t,Array.isArray(e)?e:[e]);gX[n]||(gX[n]=new WeakMap);var a=gX[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(mX.get(e)||0)+1,l=(a.get(e)||0)+1;mX.set(e,c),a.set(e,l),o.push(e),c===1&&i&&hX.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),_X++,function(){o.forEach(function(e){var t=mX.get(e)-1,i=a.get(e)-1;mX.set(e,t),a.set(e,i),t||(hX.has(e)||e.removeAttribute(r),hX.delete(e)),i||e.removeAttribute(n)}),_X--,_X||(mX=new WeakMap,mX=new WeakMap,hX=new WeakMap,gX={})}},xX=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||pX(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),bX(r,i,n,`aria-hidden`)):function(){return null}},SX=Object.defineProperty,CX=(e,t)=>SX(e,`name`,{value:t,configurable:!0}),wX=`Dialog`,[TX,EX]=mq(wX),[DX,OX]=TX(wX),kX=CX(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=y.useRef(null),c=y.useRef(null),{nodes:l,registry:u}=OJ(),[d,f]=Aq({prop:r,defaultProp:i??!1,onChange:a,caller:wX}),[p,m]=y.useState(0),[h,g]=y.useState(0);return(0,G.jsx)(DX,{scope:t,triggerRef:s,contentRef:c,contentId:xq(),titleId:xq(),descriptionId:xq(),titlePresent:p>0,descriptionPresent:h>0,setTitleCount:m,setDescriptionCount:g,open:d,onOpenChange:f,onOpenToggle:y.useCallback(()=>f(e=>!e),[f]),modal:o,branchNodes:l,branchRegistry:u,children:n})},`Dialog`),AX=`DialogPortal`,[jX,MX]=TX(AX,{forceMount:void 0}),NX=CX(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=OX(AX,t);return(0,G.jsx)(jX,{scope:t,forceMount:n,children:y.Children.map(r,e=>(0,G.jsx)(KJ,{present:n||a.open,children:(0,G.jsx)(HJ,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),PX=`DialogOverlay`,FX=y.forwardRef(CX(function(e,t){let n=MX(PX,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=OX(PX,e.__scopeDialog);return a.modal?(0,G.jsx)(KJ,{present:r||a.open,children:(0,G.jsx)(LX,{...i,ref:t})}):null},`DialogOverlay`)),IX=Lq(`DialogOverlay.RemoveScroll`),LX=y.forwardRef(CX(function(e,t){let{__scopeDialog:n,...r}=e,i=OX(PX,n),a=uq(t,mJ());return(0,G.jsx)(fX,{as:IX,allowPinchZoom:!0,shards:y.useMemo(()=>[i.contentRef,...i.branchNodes.map(e=>({current:e}))],[i.contentRef,i.branchNodes]),children:(0,G.jsx)(eJ.div,{"data-state":WX(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),RX=`DialogContent`,zX=y.forwardRef(CX(function(e,t){let n=MX(RX,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=OX(RX,e.__scopeDialog);return(0,G.jsx)(KJ,{present:r||a.open,children:a.modal?(0,G.jsx)(BX,{...i,ref:t}):(0,G.jsx)(VX,{...i,ref:t})})},`DialogContent`)),BX=y.forwardRef(CX(function(e,t){let n=OX(RX,e.__scopeDialog),r=y.useRef(null),i=uq(t,n.contentRef,r);return y.useEffect(()=>{let e=r.current;if(e)return xX(e)},[]),(0,G.jsx)(HX,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:tq(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:tq(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:tq(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),VX=y.forwardRef(CX(function(e,t){let n=OX(RX,e.__scopeDialog),r=y.useRef(!1),i=y.useRef(!1);return(0,G.jsx)(HX,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),HX=y.forwardRef(CX(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,"aria-describedby":o,children:s,...c}=e,l=OX(RX,n);return rY(),(0,G.jsx)(DJ,{registry:l.branchRegistry,children:(0,G.jsx)(TJ,{asChild:!0,loop:!0,trapped:r,branches:l.branchNodes,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,G.jsx)(pJ,{role:`dialog`,id:l.contentId,"aria-labelledby":l.titlePresent?l.titleId:void 0,"aria-describedby":l.descriptionPresent?UX(o,l.descriptionId):o,"data-state":WX(l.open),...c,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1),children:s})})})},`DialogContentImpl`));function UX(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}CX(UX,`concatAriaDescribedby`);function WX(e){return e?`open`:`closed`}CX(WX,`getState`);var GX=`[cmdk-group=""]`,KX=`[cmdk-group-items=""]`,qX=`[cmdk-group-heading=""]`,JX=`[cmdk-item=""]`,YX=`${JX}:not([aria-disabled="true"])`,XX=`cmdk-item-select`,ZX=`data-value`,QX=(e,t,n)=>ZK(e,t,n),$X=y.createContext(void 0),eZ=()=>y.useContext($X),tZ=y.createContext(void 0),nZ=()=>y.useContext(tZ),rZ=y.createContext(void 0),iZ=y.forwardRef((e,t)=>{let n=vZ(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=vZ(()=>new Set),i=vZ(()=>new Map),a=vZ(()=>new Map),o=vZ(()=>new Set),s=gZ(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=xq(),b=xq(),x=xq(),S=y.useRef(null),C=xZ();_Z(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),_Z(()=>{C(6,A)},[]);let w=y.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),C(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(x);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=j()?.id,w.emit()}),r||C(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=y.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),C(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();C(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:x,labelId:b,listInnerRef:S}),[]);function E(e,t){let r=s.current?.filter??QX;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=S.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(KX);t?t.appendChild(e.parentElement===t?e:e.closest(`${KX} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${KX} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=S.current?.querySelector(`${GX}[${ZX}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(ZX);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(GX)?.querySelector(qX))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return S.current?.querySelector(`${JX}[aria-selected="true"]`)}function M(){return Array.from(S.current?.querySelectorAll(YX)||[])}function N(e){let t=M()[e];t&&w.setState(`value`,t.getAttribute(ZX))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(ZX))}function F(e){let t=j()?.closest(GX),n;for(;t&&!n;)t=e>0?mZ(t,GX):hZ(t,GX),n=t?.querySelector(YX);n?w.setState(`value`,n.getAttribute(ZX)):P(e)}let I=()=>N(M().length-1),L=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):P(1)},R=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?F(-1):P(-1)};return y.createElement(eJ.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&L(e);break;case`ArrowDown`:L(e);break;case`p`:case`k`:g&&e.ctrlKey&&R(e);break;case`ArrowUp`:R(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(XX);t.dispatchEvent(e)}}}}},y.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:wZ},c),CZ(e,e=>y.createElement(tZ.Provider,{value:w},y.createElement($X.Provider,{value:T},e))))}),aZ=y.forwardRef((e,t)=>{let n=xq(),r=y.useRef(null),i=y.useContext(rZ),a=eZ(),o=gZ(e),s=o.current?.forceMount??i?.forceMount;_Z(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=bZ(n,r,[e.value,e.children,r],e.keywords),l=nZ(),u=yZ(e=>e.value&&e.value===c.current),d=yZ(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);y.useEffect(()=>{let t=r.current;if(t&&!e.disabled)return t.addEventListener(XX,f),()=>t.removeEventListener(XX,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...b}=e;return y.createElement(eJ.div,{ref:lq(r,t),...b,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),oZ=y.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=xq(),s=y.useRef(null),c=y.useRef(null),l=xq(),u=eZ(),d=yZ(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));_Z(()=>u.group(o),[]),bZ(o,s,[e.value,e.heading,c]);let f=y.useMemo(()=>({id:o,forceMount:i}),[i]);return y.createElement(eJ.div,{ref:lq(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&y.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),CZ(e,e=>y.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},y.createElement(rZ.Provider,{value:f},e))))}),sZ=y.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=y.useRef(null),a=yZ(e=>!e.search);return!n&&!a?null:y.createElement(eJ.div,{ref:lq(i,t),...r,"cmdk-separator":``,role:`separator`})}),cZ=y.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=nZ(),o=yZ(e=>e.search),s=yZ(e=>e.selectedItemId),c=eZ();return y.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),y.createElement(eJ.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),lZ=y.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=y.useRef(null),o=y.useRef(null),s=yZ(e=>e.selectedItemId),c=eZ();return y.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),y.createElement(eJ.div,{ref:lq(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},CZ(e,e=>y.createElement(`div`,{ref:lq(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),uZ=y.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return y.createElement(kX,{open:n,onOpenChange:r},y.createElement(NX,{container:o},y.createElement(FX,{"cmdk-overlay":``,className:i}),y.createElement(zX,{"aria-label":e.label,"cmdk-dialog":``,className:a},y.createElement(iZ,{ref:t,...s}))))}),dZ=y.forwardRef((e,t)=>yZ(e=>e.filtered.count===0)?y.createElement(eJ.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),fZ=y.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return y.createElement(eJ.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},CZ(e,e=>y.createElement(`div`,{"aria-hidden":!0},e)))}),pZ=Object.assign(iZ,{List:lZ,Item:aZ,Input:cZ,Group:oZ,Separator:sZ,Dialog:uZ,Empty:dZ,Loading:fZ});function mZ(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function hZ(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function gZ(e){let t=y.useRef(e);return _Z(()=>{t.current=e}),t}var _Z=typeof window>`u`?y.useEffect:y.useLayoutEffect;function vZ(e){let t=y.useRef();return t.current===void 0&&(t.current=e()),t}function yZ(e){let t=nZ(),n=()=>e(t.snapshot());return y.useSyncExternalStore(t.subscribe,n,n)}function bZ(e,t,n,r=[]){let i=y.useRef(),a=eZ();return _Z(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(ZX,s),i.current=s}),i}var xZ=()=>{let[e,t]=y.useState(),n=vZ(()=>new Map);return _Z(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function SZ(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function CZ({asChild:e,children:t},n){return e&&y.isValidElement(t)?y.cloneElement(SZ(t),{ref:t.ref},n(t.props.children)):n(t)}var wZ={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},TZ=y.createContext(void 0);function EZ(e){let t=y.useContext(TZ);if(!e&&t===void 0)throw Error(Ds(27));return t}var DZ=y.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=EZ(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return Zs(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:od,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),OZ=y.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=EZ(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=Ns({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,jp(zp,e.nativeEvent))}return Zs(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),kZ=y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=EZ(),c=OI(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),Zs(`p`,e,{ref:t,props:[{id:c},o]})}),AZ=y.createContext(void 0);function jZ(){let e=y.useContext(AZ);if(e===void 0)throw Error(Ds(26));return e}var MZ=`--nested-dialogs`,NZ=`data-nested-dialog-open`,PZ={...ad,...Ku,nestedDialogOpen(e){return e?{[NZ]:``}:null}},FZ=y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=EZ(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);jZ(),Yf({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?ih(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=Zs(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...rh,hidden:!m,onKeyDown(e){GI.has(e.key)&&e.stopPropagation()},style:{[MZ]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:PZ});return(0,G.jsx)(Km,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),IZ=y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=EZ(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,G.jsx)(AZ.Provider,{value:n,children:(0,G.jsxs)(nm,{ref:t,...r,children:[a&&o===!0&&(0,G.jsx)(_L,{ref:i.context.internalBackdropRef,inert:Bf(!s)}),e.children]})}):null});function LZ({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`mounted`),a=e.useState(`disablePointerDismissal`),o=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=y.useState(0),[d,f]=y.useState(0),p=l===0,m=$m(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Fu(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Q(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return kL(r&&o===!0,s),e.useContextCallback(`onNestedDialogOpen`,(t,n)=>{(e.select(`open`)||e.select(`mounted`))&&(u(t),f(n))}),Y(()=>{!r&&!i&&(u(0),f(0))},[r,i]),Y(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(l+1,d+ +!!n),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),hh(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var RZ={...Eh,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},zZ=class extends au{constructor(e,t,n){let r=new _h,i=BZ(e,r,t,n);super(i,VZ(r),RZ)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(lh(this.state,e,t.trigger)))}};function BZ(e,t,n,r=!1){return{...bh(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function VZ(e){return{popupRef:y.createRef(),backdropRef:y.createRef(),internalBackdropRef:y.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function HZ(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=EZ(!0),b={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},x=ah((e,t)=>new zZ({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...b},e,t),!0);x.useControlledProp(`openProp`,r),x.useControlledProp(`triggerIdProp`,d),x.useSyncedValues(b),x.useContextCallback(`onOpenChange`,a),x.useContextCallback(`onOpenChangeComplete`,o);let S=x.useState(`open`),C=x.useState(`mounted`),w=x.useState(`payload`);gh(x,S),ph(x);let{forceUnmount:T}=mh(S,x);y.useImperativeHandle(l,()=>({unmount:T,close:()=>x.setOpen(!1,jp(Xp))}),[T,x]);let E=S||C||u!=null;return(0,G.jsxs)(TZ.Provider,{value:x,children:[u&&(0,G.jsx)(oh,{handle:u,store:x}),E&&(0,G.jsx)(LZ,{store:x,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:w}):n]})}var UZ=Yl(function(e){return HZ(`dialog`,e)}),WZ=y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=EZ(),c=OI(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),Zs(`h2`,e,{ref:t,props:[{id:c},o]})});function GZ({...e}){return(0,G.jsx)(UZ,{"data-slot":`dialog`,...e})}function KZ({...e}){return(0,G.jsx)(IZ,{"data-slot":`dialog-portal`,...e})}function qZ({className:e,...t}){return(0,G.jsx)(DZ,{"data-slot":`dialog-overlay`,className:X(`fixed inset-0 isolate z-50 bg-black/20 duration-100 motion-reduce:animate-none! dark:bg-black/45 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function JZ({className:e,children:t,showCloseButton:n=!0,...r}){return(0,G.jsxs)(KZ,{children:[(0,G.jsx)(qZ,{}),(0,G.jsxs)(FZ,{"data-slot":`dialog-content`,className:X(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border border-border bg-popover p-4 text-[12px] text-popover-foreground shadow-[0_24px_64px_rgba(0,0,0,0.35)] duration-100 outline-none motion-reduce:animate-none! sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,G.jsxs)(OZ,{"data-slot":`dialog-close`,render:(0,G.jsx)(il,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,G.jsx)(br,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function YZ({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`dialog-header`,className:X(`flex flex-col gap-2`,e),...t})}function XZ({className:e,...t}){return(0,G.jsx)(WZ,{"data-slot":`dialog-title`,className:X(`font-heading text-base leading-none font-medium`,e),...t})}function ZZ({className:e,...t}){return(0,G.jsx)(kZ,{"data-slot":`dialog-description`,className:X(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function QZ({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:X(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,e),...t})}var $Z=lc(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function eQ({className:e,align:t=`inline-start`,...n}){return(0,G.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:X($Z({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}function tQ({className:e,...t}){return(0,G.jsx)(pZ,{"data-slot":`command`,className:X(`flex size-full flex-col overflow-hidden rounded-xl! bg-popover text-popover-foreground`,e),...t})}function nQ({title:e=`Command Palette`,description:t=`Search for a command to run...`,children:n,className:r,showCloseButton:i=!1,...a}){return(0,G.jsxs)(GZ,{...a,children:[(0,G.jsxs)(YZ,{className:`sr-only`,children:[(0,G.jsx)(XZ,{children:e}),(0,G.jsx)(ZZ,{children:t})]}),(0,G.jsx)(JZ,{className:X(`top-[120px] translate-y-0 gap-0 overflow-hidden rounded-xl! p-0 sm:max-w-[560px]`,r),showCloseButton:i,children:n})]})}function rQ({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`command-input-wrapper`,children:(0,G.jsxs)(QZ,{className:`h-12 rounded-none! border-0 border-b border-border bg-transparent px-2 shadow-none! dark:bg-transparent *:data-[slot=input-group-addon]:pl-2!`,children:[(0,G.jsx)(pZ.Input,{"data-slot":`command-input`,className:X(`w-full text-[14px] outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,e),...t}),(0,G.jsx)(eQ,{children:(0,G.jsx)(Kn,{className:`size-4 shrink-0 opacity-50`})})]})})}function iQ({className:e,...t}){return(0,G.jsx)(pZ.List,{"data-slot":`command-list`,className:X(`no-scrollbar max-h-[420px] scroll-py-2 overflow-x-hidden overflow-y-auto outline-none`,e),...t})}function aQ({className:e,...t}){return(0,G.jsx)(pZ.Empty,{"data-slot":`command-empty`,className:X(`py-6 text-center text-body text-muted-foreground`,e),...t})}function oQ({className:e,...t}){return(0,G.jsx)(pZ.Group,{"data-slot":`command-group`,className:X(`overflow-hidden px-2 py-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-[11px] **:[[cmdk-group-heading]]:font-semibold **:[[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function sQ({className:e,children:t,...n}){return(0,G.jsx)(pZ.Item,{"data-slot":`command-item`,className:X(`group/command-item relative flex h-[34px] cursor-default items-center gap-2.5 rounded-[7px] px-2 text-body outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-accent data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:text-muted-foreground [&_svg:not([class*='size-'])]:size-[15px]`,e),...n,children:t})}function cQ({className:e,...t}){return(0,G.jsx)(`kbd`,{"data-slot":`kbd`,className:X(`pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground select-none in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 [&_svg:not([class*='size-'])]:size-3`,e),...t})}function lQ({className:e,...t}){return(0,G.jsx)(`kbd`,{"data-slot":`kbd-group`,className:X(`inline-flex items-center gap-1`,e),...t})}var uQ=ue()(()=>({open:null}));function dQ(e){uQ.setState({open:e})}function fQ(){return fe(uQ,e=>e.open)}function pQ(e,t){let n=e.projects.find(e=>e.name===t);return{projects:e.projects.map(({name:e})=>({ref:e,label:e})),pages:(n?.pages??[]).map(e=>({ref:e.ref,label:e.name})),frames:(n?.pages??[]).flatMap(e=>e.frames.filter(e=>!e.hidden).map(t=>({ref:t.ref,label:t.name,hint:e.name})))}}function mQ(e){F(`/p/${encodeURIComponent(e)}`)}function hQ(e){let[t=``,n=``]=e.split(`/`);F(z(t,n))}function gQ(e){let[t=``,n=``]=e.split(`/`),r=`${t}/${n}`;qH(r,()=>sD(bD,r,[e]))}function _Q(){let e=fQ()===`commands`;return(0,G.jsx)(nQ,{open:e,onOpenChange:e=>dQ(e?`commands`:null),title:`Command palette`,description:`Search for a frame, page, project, or action to run.`,children:(0,G.jsx)(vQ,{})})}function vQ(){let e=Z(e=>e.board),[,t]=Br(`/p/:project/:page?`),n=Te().filter(e=>!(e.group===`mode`&&e.checked?.())),{frames:r,pages:i,projects:a}=e?pQ(e,t?.project??null):{frames:[],pages:[],projects:[]},o=e=>()=>{dQ(null),e()},s=(e,t,n,r)=>e.map(e=>(0,G.jsxs)(sQ,{value:`${r}:${e.ref}`,keywords:[e.label,e.hint??``],onSelect:o(()=>n(e.ref)),children:[t,(0,G.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.hint?(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:e.hint}):null]},e.ref));return(0,G.jsxs)(tQ,{filter:bQ,children:[(0,G.jsx)(rQ,{placeholder:`Search frames, pages, and actions`}),(0,G.jsxs)(iQ,{children:[(0,G.jsx)(aQ,{children:`Nothing matches.`}),r.length>0?(0,G.jsx)(oQ,{heading:`Frames`,children:s(r,(0,G.jsx)(Xn,{}),gQ,`frame`)}):null,i.length>0?(0,G.jsx)(oQ,{heading:`Pages`,children:s(i,(0,G.jsx)(Lt,{}),hQ,`page`)}):null,n.length>0?(0,G.jsx)(oQ,{heading:`Actions`,children:n.map(e=>(0,G.jsx)(yQ,{action:e,choose:o},e.id))}):null,a.length>0?(0,G.jsx)(oQ,{heading:`Projects`,children:s(a,(0,G.jsx)(qt,{}),mQ,`project`)}):null]})]})}function yQ({action:e,choose:t}){let n=e.command?.label??e.label,r=e.command?.icon??Tt,i=e.keys?.[0];return(0,G.jsxs)(sQ,{value:`action:${e.id}`,keywords:[n],onSelect:t(e.run),children:[(0,G.jsx)(r,{}),(0,G.jsx)(`span`,{className:`flex-1 truncate`,children:n}),i?(0,G.jsx)(lQ,{children:RF(i).map(e=>(0,G.jsx)(cQ,{children:e},e))}):null]})}function bQ(e,t,n=[]){let r=t.trim().toLowerCase();return r===``?1:Math.max(...n.map(e=>{let t=e.toLowerCase();return t.startsWith(r)?1:t.includes(r)?.8:xQ(t,r)?.3:0}))}function xQ(e,t){let n=0;for(let r of t)if(n=e.indexOf(r,n)+1,n===0)return!1;return!0}var SQ=IF?`⌘`:`Ctrl`,CQ=IF?`⇧`:`Shift`,wQ=IF?`⌃`:`Ctrl`,TQ=[{title:`Tools`,rows:[{label:`Move`,actions:[`tool.move`]},{label:`Hand`,actions:[`tool.hand`]},{label:`Frame`,actions:[`tool.frame`]},{label:`Note`,actions:[`tool.note`]},{label:`Find`,actions:[`find.open`]},{label:`Command palette`,actions:[`palette.open`]},{label:`This list`,actions:[`help.shortcuts`]}]},{title:`Selection`,rows:[{label:`Into an element`,gestures:[`${SQ} click`]},{label:`One level down`,actions:[`element.down`]},{label:`One level up`,actions:[`element.up`]},{label:`Next sibling`,actions:[`element.next`]},{label:`Add to selection`,gestures:[`${CQ} click`]}]},{title:`View`,rows:[{label:`Zoom to fit`,actions:[`view.zoomToFit`]},{label:`Zoom to selection`,actions:[`view.zoomToSelection`]},{label:`Hide UI`,actions:[`view.hideUi`]},{label:`Undo`,actions:[`edit.undo`]},{label:`Redo`,actions:[`edit.redo`]}]},{title:`Frames`,rows:[{label:`Nudge`,gestures:[`Arrows`]},{label:`Bigger nudge`,gestures:[`${CQ} Arrows`]},{label:`Resize`,gestures:[`${SQ} Arrows`]},{label:`Duplicate`,actions:[`frame.duplicate`]},{label:`Copy as PNG`,actions:[`frame.copyPng`]},{label:`Hide`,actions:[`frame.hide`]},{label:`Lock`,actions:[`frame.lock`]},{label:`Delete`,actions:[`frame.delete`]}]},{title:`Arrange`,rows:[{label:`Align left, right`,actions:[`arrange.alignLeft`,`arrange.alignRight`]},{label:`Align top, bottom`,actions:[`arrange.alignTop`,`arrange.alignBottom`]},{label:`Center`,actions:[`arrange.alignCenter`,`arrange.alignMiddle`]},{label:`Distribute`,actions:[`arrange.distributeHorizontal`,`arrange.distributeVertical`]},{label:`Snap off while dragging`,gestures:[`${wQ} drag`]}]}],EQ=TQ.flatMap(e=>e.rows.flatMap(e=>e.actions??[]));function DQ(){let e=fQ()===`shortcuts`,t=Ce(EQ),n=new Map(EQ.map((e,n)=>[e,t[n]]));return(0,G.jsx)(GZ,{open:e,onOpenChange:e=>dQ(e?`shortcuts`:null),children:(0,G.jsxs)(JZ,{showCloseButton:!1,className:`top-[90px] translate-y-0 gap-0 p-0 sm:max-w-[760px]`,children:[(0,G.jsxs)(`div`,{className:`flex h-12 items-center justify-between border-b border-border px-4 text-[14px]`,children:[(0,G.jsx)(XZ,{className:`text-[14px] leading-none font-semibold`,children:`Keyboard shortcuts`}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Esc`})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-x-7 gap-y-[18px] px-5 pt-4 pb-5`,children:TQ.map(e=>(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`h3`,{className:`pb-1.5 text-label text-muted-foreground`,children:e.title}),(0,G.jsx)(`ul`,{children:e.rows.map(e=>(0,G.jsx)(OQ,{row:e,byId:n},e.label))})]},e.title))})]})})}function OQ({row:e,byId:t}){let n=[...(e.actions??[]).flatMap(e=>{let n=t.get(e)?.keys?.[0];return n?[RF(n).join(IF?` `:`+`)]:[]}),...e.gestures??[]],r=e.actions!==void 0&&e.actions.every(e=>!t.get(e));return(0,G.jsxs)(`li`,{"aria-disabled":r||void 0,className:`flex h-[26px] items-center justify-between aria-disabled:text-faint`,children:[(0,G.jsx)(`span`,{children:e.label}),(0,G.jsx)(lQ,{children:n.map(e=>(0,G.jsx)(cQ,{className:`px-1.5 text-label font-normal`,children:e},e))})]})}var kQ=1.6;function AQ(){return(0,G.jsx)(Ve,{strokeWidth:kQ,children:(0,G.jsx)(cB,{delay:500,children:(0,G.jsxs)(L_,{children:[(0,G.jsx)(jQ,{}),(0,G.jsx)(_Q,{}),(0,G.jsx)(DQ,{})]})})})}function jQ(){let e=Z(e=>e.board?.projects),t=Z(e=>e.connected);return(0,G.jsxs)(`div`,{className:`relative h-svh overflow-auto bg-background text-foreground`,children:[e?(0,G.jsxs)(qr,{children:[(0,G.jsx)(Wr,{path:`/`,children:(0,G.jsx)(IK,{projects:e})}),(0,G.jsx)(Wr,{path:`/p/:project/:page`,children:({project:e,page:t})=>(0,G.jsx)(YG,{project:e,page:t})}),(0,G.jsx)(Wr,{path:`/p/:project`,children:({project:e})=>(0,G.jsx)(YG,{project:e})}),(0,G.jsx)(Wr,{children:(0,G.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-6`,children:[(0,G.jsx)(`p`,{className:`text-body text-muted-foreground`,children:`Nothing on the board at this address.`}),(0,G.jsx)(Gr,{href:`/`,className:rl({variant:`outline`}),children:`Go home`})]})})]}):(0,G.jsx)(`p`,{role:`status`,className:`flex h-full items-center justify-center text-body text-muted-foreground`,children:`Connecting to the board`}),e&&!t?(0,G.jsx)(`p`,{role:`status`,className:`absolute top-3 left-1/2 -translate-x-1/2 rounded-xl border border-border bg-card px-3 py-1 text-body text-muted-foreground`,children:`Reconnecting to frameboard serve`}):null]})}function MQ({store:e=yl,calls:t=WE,navigate:n=F,selection:r=bD,notify:i=e=>E_.add({...e,type:`warning`,timeout:0})}={}){let a=e=>{RE(e.frames);for(let[t,n]of Object.entries(e.hashes??{}))gD(t,n);let t=r.getState(),i=t.element?e.hashes?.[t.element.frame]:void 0;if(t.page&&t.element&&i&&cD(r,t.page,{...t.element,hash:i}),e.page===null)return;let[a=``,o=``]=e.page.split(`/`);n(z(a,o))},o=(t,n,o)=>()=>{let s=()=>{},c=e.getState().history;xE([],o,()=>(s=mD(null),t().catch(e=>{throw s(),e})),{live:e,dropWhen:({history:e})=>e.undo!==c.undo||e.redo!==c.redo}).then(e=>{s(),a(e),yD(r,sH)},e=>{s(),vD(r,sH),e instanceof jl&&e.code!==`nothing-to-undo`&&i({title:n,description:e.message})})},s=t=>()=>{let{canWrite:n,history:r}=e.getState();return n&&r[t]>0},c=be([{id:`edit.undo`,label:`Undo`,group:`edit`,keys:[`$mod+KeyZ`],run:o(t.undo,`Undo skipped`,`undo`),enabled:s(`undo`),command:{label:`Undo`,icon:gr}},{id:`edit.redo`,label:`Redo`,group:`edit`,keys:[`$mod+Shift+KeyZ`],run:o(t.redo,`Redo skipped`,`redo`),enabled:s(`redo`),command:{label:`Redo`,icon:Rn}}]),l=e.subscribe((e,t)=>{(e.history!==t.history||e.canWrite!==t.canWrite)&&xe()});return()=>{l(),c()}}function NQ(){return be([{id:`palette.open`,label:`Command palette`,group:`help`,keys:[`$mod+KeyK`],run:()=>dQ(`commands`)},{id:`help.shortcuts`,label:`Keyboard shortcuts`,group:`help`,keys:[`Shift+?`],run:()=>dQ(`shortcuts`),command:{label:`Keyboard shortcuts`,icon:yt}}])}var PQ=[{choice:`system`,label:`System`},{choice:`light`,label:`Light`},{choice:`dark`,label:`Dark`}];function FQ(e=ov){let t=be([{id:`theme.toggle`,label:`Theme`,group:`view`,command:{label:`Toggle theme`,icon:Qn},run:()=>Q_(e)},...PQ.map(({choice:t,label:n})=>({id:`theme.${t}`,label:n,group:`theme`,run:()=>Z_(t,e),checked:()=>e.getState().choice===t}))]),n=e.subscribe(xe);return()=>{n(),t()}}var IQ=document.getElementById(`root`);if(!IQ)throw Error(`Missing #root element`);PN(yl,{onShow:e=>{let[t=``,n=``]=e.split(`/`);F(z(t,n)),yl.setState({focus:e})}}),Y_(ov,X_(window)),FQ(),MQ(),NQ(),De(window),(0,b.createRoot)(IQ).render((0,G.jsx)(y.StrictMode,{children:(0,G.jsx)(AQ,{})}));
111
+ `},cX=0,lX=[];function uX(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),i=y.useState(cX++)[0],a=y.useState(MY)[0],o=y.useRef(e);y.useEffect(function(){o.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=cY([e.lockRef.current],(e.shards||[]).map(aX),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=y.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=rX(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=XY(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=XY(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return nX(h,t,e,h===`h`?s:c,!0)},[]),c=y.useCallback(function(e){var n=e;if(lX.length&&lX[lX.length-1]===a){var r=`deltaY`in n?iX(n):rX(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&oX(e.delta,r)})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var c=(o.current.shards||[]).map(aX).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=y.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:dX(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=y.useCallback(function(e){n.current=rX(e),r.current=void 0},[]),d=y.useCallback(function(t){l(t.type,iX(t),t.target,s(t,e.lockRef.current))},[]),f=y.useCallback(function(t){l(t.type,rX(t),t.target,s(t,e.lockRef.current))},[]);y.useEffect(function(){return lX.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,GY),document.addEventListener(`touchmove`,c,GY),document.addEventListener(`touchstart`,u,GY),function(){lX=lX.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,GY),document.removeEventListener(`touchmove`,c,GY),document.removeEventListener(`touchstart`,u,GY)}},[]);var p=e.removeScrollBar,m=e.inert;return y.createElement(y.Fragment,null,m?y.createElement(a,{styles:sX(i)}):null,p?y.createElement(HY,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function dX(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var fX=SY(CY,uX),pX=y.forwardRef(function(e,t){return y.createElement(TY,oY({},e,{ref:t,sideCar:fX}))});pX.classNames=TY.classNames;var mX=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},hX=new WeakMap,gX=new WeakMap,_X={},vX=0,yX=function(e){return e&&(e.host||yX(e.parentNode))},bX=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=yX(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},xX=function(e,t,n,r){var i=bX(t,Array.isArray(e)?e:[e]);_X[n]||(_X[n]=new WeakMap);var a=_X[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(hX.get(e)||0)+1,l=(a.get(e)||0)+1;hX.set(e,c),a.set(e,l),o.push(e),c===1&&i&&gX.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),vX++,function(){o.forEach(function(e){var t=hX.get(e)-1,i=a.get(e)-1;hX.set(e,t),a.set(e,i),t||(gX.has(e)||e.removeAttribute(r),gX.delete(e)),i||e.removeAttribute(n)}),vX--,vX||(hX=new WeakMap,hX=new WeakMap,gX=new WeakMap,_X={})}},SX=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||mX(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),xX(r,i,n,`aria-hidden`)):function(){return null}},CX=Object.defineProperty,wX=(e,t)=>CX(e,`name`,{value:t,configurable:!0}),TX=`Dialog`,[EX,DX]=hq(TX),[OX,kX]=EX(TX),AX=wX(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=y.useRef(null),c=y.useRef(null),{nodes:l,registry:u}=kJ(),[d,f]=jq({prop:r,defaultProp:i??!1,onChange:a,caller:TX}),[p,m]=y.useState(0),[h,g]=y.useState(0);return(0,G.jsx)(OX,{scope:t,triggerRef:s,contentRef:c,contentId:Sq(),titleId:Sq(),descriptionId:Sq(),titlePresent:p>0,descriptionPresent:h>0,setTitleCount:m,setDescriptionCount:g,open:d,onOpenChange:f,onOpenToggle:y.useCallback(()=>f(e=>!e),[f]),modal:o,branchNodes:l,branchRegistry:u,children:n})},`Dialog`),jX=`DialogPortal`,[MX,NX]=EX(jX,{forceMount:void 0}),PX=wX(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=kX(jX,t);return(0,G.jsx)(MX,{scope:t,forceMount:n,children:y.Children.map(r,e=>(0,G.jsx)(qJ,{present:n||a.open,children:(0,G.jsx)(UJ,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),FX=`DialogOverlay`,IX=y.forwardRef(wX(function(e,t){let n=NX(FX,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=kX(FX,e.__scopeDialog);return a.modal?(0,G.jsx)(qJ,{present:r||a.open,children:(0,G.jsx)(RX,{...i,ref:t})}):null},`DialogOverlay`)),LX=Rq(`DialogOverlay.RemoveScroll`),RX=y.forwardRef(wX(function(e,t){let{__scopeDialog:n,...r}=e,i=kX(FX,n),a=dq(t,hJ());return(0,G.jsx)(pX,{as:LX,allowPinchZoom:!0,shards:y.useMemo(()=>[i.contentRef,...i.branchNodes.map(e=>({current:e}))],[i.contentRef,i.branchNodes]),children:(0,G.jsx)(tJ.div,{"data-state":GX(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),zX=`DialogContent`,BX=y.forwardRef(wX(function(e,t){let n=NX(zX,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=kX(zX,e.__scopeDialog);return(0,G.jsx)(qJ,{present:r||a.open,children:a.modal?(0,G.jsx)(VX,{...i,ref:t}):(0,G.jsx)(HX,{...i,ref:t})})},`DialogContent`)),VX=y.forwardRef(wX(function(e,t){let n=kX(zX,e.__scopeDialog),r=y.useRef(null),i=dq(t,n.contentRef,r);return y.useEffect(()=>{let e=r.current;if(e)return SX(e)},[]),(0,G.jsx)(UX,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:nq(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:nq(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:nq(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),HX=y.forwardRef(wX(function(e,t){let n=kX(zX,e.__scopeDialog),r=y.useRef(!1),i=y.useRef(!1);return(0,G.jsx)(UX,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),UX=y.forwardRef(wX(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,"aria-describedby":o,children:s,...c}=e,l=kX(zX,n);return iY(),(0,G.jsx)(OJ,{registry:l.branchRegistry,children:(0,G.jsx)(EJ,{asChild:!0,loop:!0,trapped:r,branches:l.branchNodes,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,G.jsx)(mJ,{role:`dialog`,id:l.contentId,"aria-labelledby":l.titlePresent?l.titleId:void 0,"aria-describedby":l.descriptionPresent?WX(o,l.descriptionId):o,"data-state":GX(l.open),...c,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1),children:s})})})},`DialogContentImpl`));function WX(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}wX(WX,`concatAriaDescribedby`);function GX(e){return e?`open`:`closed`}wX(GX,`getState`);var KX=`[cmdk-group=""]`,qX=`[cmdk-group-items=""]`,JX=`[cmdk-group-heading=""]`,YX=`[cmdk-item=""]`,XX=`${YX}:not([aria-disabled="true"])`,ZX=`cmdk-item-select`,QX=`data-value`,$X=(e,t,n)=>QK(e,t,n),eZ=y.createContext(void 0),tZ=()=>y.useContext(eZ),nZ=y.createContext(void 0),rZ=()=>y.useContext(nZ),iZ=y.createContext(void 0),aZ=y.forwardRef((e,t)=>{let n=yZ(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=yZ(()=>new Set),i=yZ(()=>new Map),a=yZ(()=>new Map),o=yZ(()=>new Set),s=_Z(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Sq(),b=Sq(),x=Sq(),S=y.useRef(null),C=SZ();vZ(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),vZ(()=>{C(6,A)},[]);let w=y.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),C(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(x);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=j()?.id,w.emit()}),r||C(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=y.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),C(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();C(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:x,labelId:b,listInnerRef:S}),[]);function E(e,t){let r=s.current?.filter??$X;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=S.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(qX);t?t.appendChild(e.parentElement===t?e:e.closest(`${qX} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${qX} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=S.current?.querySelector(`${KX}[${QX}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(QX);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(KX)?.querySelector(JX))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return S.current?.querySelector(`${YX}[aria-selected="true"]`)}function M(){return Array.from(S.current?.querySelectorAll(XX)||[])}function N(e){let t=M()[e];t&&w.setState(`value`,t.getAttribute(QX))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(QX))}function F(e){let t=j()?.closest(KX),n;for(;t&&!n;)t=e>0?hZ(t,KX):gZ(t,KX),n=t?.querySelector(XX);n?w.setState(`value`,n.getAttribute(QX)):P(e)}let I=()=>N(M().length-1),L=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):P(1)},R=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?F(-1):P(-1)};return y.createElement(tJ.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&L(e);break;case`ArrowDown`:L(e);break;case`p`:case`k`:g&&e.ctrlKey&&R(e);break;case`ArrowUp`:R(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(ZX);t.dispatchEvent(e)}}}}},y.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:TZ},c),wZ(e,e=>y.createElement(nZ.Provider,{value:w},y.createElement(eZ.Provider,{value:T},e))))}),oZ=y.forwardRef((e,t)=>{let n=Sq(),r=y.useRef(null),i=y.useContext(iZ),a=tZ(),o=_Z(e),s=o.current?.forceMount??i?.forceMount;vZ(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=xZ(n,r,[e.value,e.children,r],e.keywords),l=rZ(),u=bZ(e=>e.value&&e.value===c.current),d=bZ(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);y.useEffect(()=>{let t=r.current;if(t&&!e.disabled)return t.addEventListener(ZX,f),()=>t.removeEventListener(ZX,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...b}=e;return y.createElement(tJ.div,{ref:uq(r,t),...b,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),sZ=y.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Sq(),s=y.useRef(null),c=y.useRef(null),l=Sq(),u=tZ(),d=bZ(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));vZ(()=>u.group(o),[]),xZ(o,s,[e.value,e.heading,c]);let f=y.useMemo(()=>({id:o,forceMount:i}),[i]);return y.createElement(tJ.div,{ref:uq(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&y.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),wZ(e,e=>y.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},y.createElement(iZ.Provider,{value:f},e))))}),cZ=y.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=y.useRef(null),a=bZ(e=>!e.search);return!n&&!a?null:y.createElement(tJ.div,{ref:uq(i,t),...r,"cmdk-separator":``,role:`separator`})}),lZ=y.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=rZ(),o=bZ(e=>e.search),s=bZ(e=>e.selectedItemId),c=tZ();return y.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),y.createElement(tJ.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),uZ=y.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=y.useRef(null),o=y.useRef(null),s=bZ(e=>e.selectedItemId),c=tZ();return y.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),y.createElement(tJ.div,{ref:uq(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},wZ(e,e=>y.createElement(`div`,{ref:uq(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),dZ=y.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return y.createElement(AX,{open:n,onOpenChange:r},y.createElement(PX,{container:o},y.createElement(IX,{"cmdk-overlay":``,className:i}),y.createElement(BX,{"aria-label":e.label,"cmdk-dialog":``,className:a},y.createElement(aZ,{ref:t,...s}))))}),fZ=y.forwardRef((e,t)=>bZ(e=>e.filtered.count===0)?y.createElement(tJ.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),pZ=y.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return y.createElement(tJ.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},wZ(e,e=>y.createElement(`div`,{"aria-hidden":!0},e)))}),mZ=Object.assign(aZ,{List:uZ,Item:oZ,Input:lZ,Group:sZ,Separator:cZ,Dialog:dZ,Empty:fZ,Loading:pZ});function hZ(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function gZ(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function _Z(e){let t=y.useRef(e);return vZ(()=>{t.current=e}),t}var vZ=typeof window>`u`?y.useEffect:y.useLayoutEffect;function yZ(e){let t=y.useRef();return t.current===void 0&&(t.current=e()),t}function bZ(e){let t=rZ(),n=()=>e(t.snapshot());return y.useSyncExternalStore(t.subscribe,n,n)}function xZ(e,t,n,r=[]){let i=y.useRef(),a=tZ();return vZ(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(QX,s),i.current=s}),i}var SZ=()=>{let[e,t]=y.useState(),n=yZ(()=>new Map);return vZ(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function CZ(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function wZ({asChild:e,children:t},n){return e&&y.isValidElement(t)?y.cloneElement(CZ(t),{ref:t.ref},n(t.props.children)):n(t)}var TZ={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},EZ=y.createContext(void 0);function DZ(e){let t=y.useContext(EZ);if(!e&&t===void 0)throw Error(Ds(27));return t}var OZ=y.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=DZ(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return Zs(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:od,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),kZ=y.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=DZ(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=Ns({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,jp(zp,e.nativeEvent))}return Zs(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),AZ=y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=DZ(),c=OI(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),Zs(`p`,e,{ref:t,props:[{id:c},o]})}),jZ=y.createContext(void 0);function MZ(){let e=y.useContext(jZ);if(e===void 0)throw Error(Ds(26));return e}var NZ=`--nested-dialogs`,PZ=`data-nested-dialog-open`,FZ={...ad,...Ku,nestedDialogOpen(e){return e?{[PZ]:``}:null}},IZ=y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=DZ(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);MZ(),Yf({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?ih(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=Zs(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...rh,hidden:!m,onKeyDown(e){GI.has(e.key)&&e.stopPropagation()},style:{[NZ]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:FZ});return(0,G.jsx)(Km,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),LZ=y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=DZ(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,G.jsx)(jZ.Provider,{value:n,children:(0,G.jsxs)(nm,{ref:t,...r,children:[a&&o===!0&&(0,G.jsx)(_L,{ref:i.context.internalBackdropRef,inert:Bf(!s)}),e.children]})}):null});function RZ({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`mounted`),a=e.useState(`disablePointerDismissal`),o=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=y.useState(0),[d,f]=y.useState(0),p=l===0,m=$m(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Fu(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Q(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return kL(r&&o===!0,s),e.useContextCallback(`onNestedDialogOpen`,(t,n)=>{(e.select(`open`)||e.select(`mounted`))&&(u(t),f(n))}),Y(()=>{!r&&!i&&(u(0),f(0))},[r,i]),Y(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(l+1,d+ +!!n),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),hh(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var zZ={...Eh,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},BZ=class extends au{constructor(e,t,n){let r=new _h,i=VZ(e,r,t,n);super(i,HZ(r),zZ)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(lh(this.state,e,t.trigger)))}};function VZ(e,t,n,r=!1){return{...bh(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function HZ(e){return{popupRef:y.createRef(),backdropRef:y.createRef(),internalBackdropRef:y.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function UZ(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=DZ(!0),b={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},x=ah((e,t)=>new BZ({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...b},e,t),!0);x.useControlledProp(`openProp`,r),x.useControlledProp(`triggerIdProp`,d),x.useSyncedValues(b),x.useContextCallback(`onOpenChange`,a),x.useContextCallback(`onOpenChangeComplete`,o);let S=x.useState(`open`),C=x.useState(`mounted`),w=x.useState(`payload`);gh(x,S),ph(x);let{forceUnmount:T}=mh(S,x);y.useImperativeHandle(l,()=>({unmount:T,close:()=>x.setOpen(!1,jp(Xp))}),[T,x]);let E=S||C||u!=null;return(0,G.jsxs)(EZ.Provider,{value:x,children:[u&&(0,G.jsx)(oh,{handle:u,store:x}),E&&(0,G.jsx)(RZ,{store:x,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:w}):n]})}var WZ=Yl(function(e){return UZ(`dialog`,e)}),GZ=y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=DZ(),c=OI(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),Zs(`h2`,e,{ref:t,props:[{id:c},o]})});function KZ({...e}){return(0,G.jsx)(WZ,{"data-slot":`dialog`,...e})}function qZ({...e}){return(0,G.jsx)(LZ,{"data-slot":`dialog-portal`,...e})}function JZ({className:e,...t}){return(0,G.jsx)(OZ,{"data-slot":`dialog-overlay`,className:X(`fixed inset-0 isolate z-50 bg-black/20 duration-100 motion-reduce:animate-none! dark:bg-black/45 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function YZ({className:e,children:t,showCloseButton:n=!0,...r}){return(0,G.jsxs)(qZ,{children:[(0,G.jsx)(JZ,{}),(0,G.jsxs)(IZ,{"data-slot":`dialog-content`,className:X(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border border-border bg-popover p-4 text-[12px] text-popover-foreground shadow-[0_24px_64px_rgba(0,0,0,0.35)] duration-100 outline-none motion-reduce:animate-none! sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,G.jsxs)(kZ,{"data-slot":`dialog-close`,render:(0,G.jsx)(il,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,G.jsx)(br,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function XZ({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`dialog-header`,className:X(`flex flex-col gap-2`,e),...t})}function ZZ({className:e,...t}){return(0,G.jsx)(GZ,{"data-slot":`dialog-title`,className:X(`font-heading text-base leading-none font-medium`,e),...t})}function QZ({className:e,...t}){return(0,G.jsx)(AZ,{"data-slot":`dialog-description`,className:X(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function $Z({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:X(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,e),...t})}var eQ=lc(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function tQ({className:e,align:t=`inline-start`,...n}){return(0,G.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:X(eQ({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}function nQ({className:e,...t}){return(0,G.jsx)(mZ,{"data-slot":`command`,className:X(`flex size-full flex-col overflow-hidden rounded-xl! bg-popover text-popover-foreground`,e),...t})}function rQ({title:e=`Command Palette`,description:t=`Search for a command to run...`,children:n,className:r,showCloseButton:i=!1,...a}){return(0,G.jsxs)(KZ,{...a,children:[(0,G.jsxs)(XZ,{className:`sr-only`,children:[(0,G.jsx)(ZZ,{children:e}),(0,G.jsx)(QZ,{children:t})]}),(0,G.jsx)(YZ,{className:X(`top-[120px] translate-y-0 gap-0 overflow-hidden rounded-xl! p-0 sm:max-w-[560px]`,r),showCloseButton:i,children:n})]})}function iQ({className:e,...t}){return(0,G.jsx)(`div`,{"data-slot":`command-input-wrapper`,children:(0,G.jsxs)($Z,{className:`h-12 rounded-none! border-0 border-b border-border bg-transparent px-2 shadow-none! dark:bg-transparent *:data-[slot=input-group-addon]:pl-2!`,children:[(0,G.jsx)(mZ.Input,{"data-slot":`command-input`,className:X(`w-full text-[14px] outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,e),...t}),(0,G.jsx)(tQ,{children:(0,G.jsx)(Kn,{className:`size-4 shrink-0 opacity-50`})})]})})}function aQ({className:e,...t}){return(0,G.jsx)(mZ.List,{"data-slot":`command-list`,className:X(`no-scrollbar max-h-[420px] scroll-py-2 overflow-x-hidden overflow-y-auto outline-none`,e),...t})}function oQ({className:e,...t}){return(0,G.jsx)(mZ.Empty,{"data-slot":`command-empty`,className:X(`py-6 text-center text-body text-muted-foreground`,e),...t})}function sQ({className:e,...t}){return(0,G.jsx)(mZ.Group,{"data-slot":`command-group`,className:X(`overflow-hidden px-2 py-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-[11px] **:[[cmdk-group-heading]]:font-semibold **:[[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function cQ({className:e,children:t,...n}){return(0,G.jsx)(mZ.Item,{"data-slot":`command-item`,className:X(`group/command-item relative flex h-[34px] cursor-default items-center gap-2.5 rounded-[7px] px-2 text-body outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-accent data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:text-muted-foreground [&_svg:not([class*='size-'])]:size-[15px]`,e),...n,children:t})}function lQ({className:e,...t}){return(0,G.jsx)(`kbd`,{"data-slot":`kbd`,className:X(`pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground select-none in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 [&_svg:not([class*='size-'])]:size-3`,e),...t})}function uQ({className:e,...t}){return(0,G.jsx)(`kbd`,{"data-slot":`kbd-group`,className:X(`inline-flex items-center gap-1`,e),...t})}var dQ=ue()(()=>({open:null}));function fQ(e){dQ.setState({open:e})}function pQ(){return fe(dQ,e=>e.open)}function mQ(e,t){let n=e.projects.find(e=>e.name===t);return{projects:e.projects.map(({name:e})=>({ref:e,label:e})),pages:(n?.pages??[]).map(e=>({ref:e.ref,label:e.name})),frames:(n?.pages??[]).flatMap(e=>e.frames.filter(e=>!e.hidden).map(t=>({ref:t.ref,label:t.name,hint:e.name})))}}function hQ(e){F(`/p/${encodeURIComponent(e)}`)}function gQ(e){let[t=``,n=``]=e.split(`/`);F(z(t,n))}function _Q(e){let[t=``,n=``]=e.split(`/`),r=`${t}/${n}`;JH(r,()=>sD(bD,r,[e]))}function vQ(){let e=pQ()===`commands`;return(0,G.jsx)(rQ,{open:e,onOpenChange:e=>fQ(e?`commands`:null),title:`Command palette`,description:`Search for a frame, page, project, or action to run.`,children:(0,G.jsx)(yQ,{})})}function yQ(){let e=Z(e=>e.board),[,t]=Br(`/p/:project/:page?`),n=Te().filter(e=>!(e.group===`mode`&&e.checked?.())),{frames:r,pages:i,projects:a}=e?mQ(e,t?.project??null):{frames:[],pages:[],projects:[]},o=e=>()=>{fQ(null),e()},s=(e,t,n,r)=>e.map(e=>(0,G.jsxs)(cQ,{value:`${r}:${e.ref}`,keywords:[e.label,e.hint??``],onSelect:o(()=>n(e.ref)),children:[t,(0,G.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.hint?(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:e.hint}):null]},e.ref));return(0,G.jsxs)(nQ,{filter:xQ,children:[(0,G.jsx)(iQ,{placeholder:`Search frames, pages, and actions`}),(0,G.jsxs)(aQ,{children:[(0,G.jsx)(oQ,{children:`Nothing matches.`}),r.length>0?(0,G.jsx)(sQ,{heading:`Frames`,children:s(r,(0,G.jsx)(Xn,{}),_Q,`frame`)}):null,i.length>0?(0,G.jsx)(sQ,{heading:`Pages`,children:s(i,(0,G.jsx)(Lt,{}),gQ,`page`)}):null,n.length>0?(0,G.jsx)(sQ,{heading:`Actions`,children:n.map(e=>(0,G.jsx)(bQ,{action:e,choose:o},e.id))}):null,a.length>0?(0,G.jsx)(sQ,{heading:`Projects`,children:s(a,(0,G.jsx)(qt,{}),hQ,`project`)}):null]})]})}function bQ({action:e,choose:t}){let n=e.command?.label??e.label,r=e.command?.icon??Tt,i=e.keys?.[0];return(0,G.jsxs)(cQ,{value:`action:${e.id}`,keywords:[n],onSelect:t(e.run),children:[(0,G.jsx)(r,{}),(0,G.jsx)(`span`,{className:`flex-1 truncate`,children:n}),i?(0,G.jsx)(uQ,{children:RF(i).map(e=>(0,G.jsx)(lQ,{children:e},e))}):null]})}function xQ(e,t,n=[]){let r=t.trim().toLowerCase();return r===``?1:Math.max(...n.map(e=>{let t=e.toLowerCase();return t.startsWith(r)?1:t.includes(r)?.8:SQ(t,r)?.3:0}))}function SQ(e,t){let n=0;for(let r of t)if(n=e.indexOf(r,n)+1,n===0)return!1;return!0}var CQ=IF?`⌘`:`Ctrl`,wQ=IF?`⇧`:`Shift`,TQ=IF?`⌃`:`Ctrl`,EQ=[{title:`Tools`,rows:[{label:`Move`,actions:[`tool.move`]},{label:`Hand`,actions:[`tool.hand`]},{label:`Frame`,actions:[`tool.frame`]},{label:`Note`,actions:[`tool.note`]},{label:`Find`,actions:[`find.open`]},{label:`Command palette`,actions:[`palette.open`]},{label:`This list`,actions:[`help.shortcuts`]}]},{title:`Selection`,rows:[{label:`Into an element`,gestures:[`${CQ} click`]},{label:`One level down`,actions:[`element.down`]},{label:`One level up`,actions:[`element.up`]},{label:`Next sibling`,actions:[`element.next`]},{label:`Add to selection`,gestures:[`${wQ} click`]}]},{title:`View`,rows:[{label:`Zoom to fit`,actions:[`view.zoomToFit`]},{label:`Zoom to selection`,actions:[`view.zoomToSelection`]},{label:`Hide UI`,actions:[`view.hideUi`]},{label:`Undo`,actions:[`edit.undo`]},{label:`Redo`,actions:[`edit.redo`]}]},{title:`Frames`,rows:[{label:`Nudge`,gestures:[`Arrows`]},{label:`Bigger nudge`,gestures:[`${wQ} Arrows`]},{label:`Resize`,gestures:[`${CQ} Arrows`]},{label:`Duplicate`,actions:[`frame.duplicate`]},{label:`Copy as PNG`,actions:[`frame.copyPng`]},{label:`Hide`,actions:[`frame.hide`]},{label:`Lock`,actions:[`frame.lock`]},{label:`Delete`,actions:[`frame.delete`]}]},{title:`Arrange`,rows:[{label:`Align left, right`,actions:[`arrange.alignLeft`,`arrange.alignRight`]},{label:`Align top, bottom`,actions:[`arrange.alignTop`,`arrange.alignBottom`]},{label:`Center`,actions:[`arrange.alignCenter`,`arrange.alignMiddle`]},{label:`Distribute`,actions:[`arrange.distributeHorizontal`,`arrange.distributeVertical`]},{label:`Snap off while dragging`,gestures:[`${TQ} drag`]}]}],DQ=EQ.flatMap(e=>e.rows.flatMap(e=>e.actions??[]));function OQ(){let e=pQ()===`shortcuts`,t=Ce(DQ),n=new Map(DQ.map((e,n)=>[e,t[n]]));return(0,G.jsx)(KZ,{open:e,onOpenChange:e=>fQ(e?`shortcuts`:null),children:(0,G.jsxs)(YZ,{showCloseButton:!1,className:`top-[90px] translate-y-0 gap-0 p-0 sm:max-w-[760px]`,children:[(0,G.jsxs)(`div`,{className:`flex h-12 items-center justify-between border-b border-border px-4 text-[14px]`,children:[(0,G.jsx)(ZZ,{className:`text-[14px] leading-none font-semibold`,children:`Keyboard shortcuts`}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Esc`})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-x-7 gap-y-[18px] px-5 pt-4 pb-5`,children:EQ.map(e=>(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`h3`,{className:`pb-1.5 text-label text-muted-foreground`,children:e.title}),(0,G.jsx)(`ul`,{children:e.rows.map(e=>(0,G.jsx)(kQ,{row:e,byId:n},e.label))})]},e.title))})]})})}function kQ({row:e,byId:t}){let n=[...(e.actions??[]).flatMap(e=>{let n=t.get(e)?.keys?.[0];return n?[RF(n).join(IF?` `:`+`)]:[]}),...e.gestures??[]],r=e.actions!==void 0&&e.actions.every(e=>!t.get(e));return(0,G.jsxs)(`li`,{"aria-disabled":r||void 0,className:`flex h-[26px] items-center justify-between aria-disabled:text-faint`,children:[(0,G.jsx)(`span`,{children:e.label}),(0,G.jsx)(uQ,{children:n.map(e=>(0,G.jsx)(lQ,{className:`px-1.5 text-label font-normal`,children:e},e))})]})}var AQ=1.6;function jQ(){return(0,G.jsx)(Ve,{strokeWidth:AQ,children:(0,G.jsx)(cB,{delay:500,children:(0,G.jsxs)(L_,{children:[(0,G.jsx)(MQ,{}),(0,G.jsx)(vQ,{}),(0,G.jsx)(OQ,{})]})})})}function MQ(){let e=Z(e=>e.board?.projects),t=Z(e=>e.connected);return(0,G.jsxs)(`div`,{className:`relative h-svh overflow-auto bg-background text-foreground`,children:[e?(0,G.jsxs)(qr,{children:[(0,G.jsx)(Wr,{path:`/`,children:(0,G.jsx)(LK,{projects:e})}),(0,G.jsx)(Wr,{path:`/p/:project/:page`,children:({project:e,page:t})=>(0,G.jsx)(XG,{project:e,page:t})}),(0,G.jsx)(Wr,{path:`/p/:project`,children:({project:e})=>(0,G.jsx)(XG,{project:e})}),(0,G.jsx)(Wr,{children:(0,G.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-6`,children:[(0,G.jsx)(`p`,{className:`text-body text-muted-foreground`,children:`Nothing on the board at this address.`}),(0,G.jsx)(Gr,{href:`/`,className:rl({variant:`outline`}),children:`Go home`})]})})]}):(0,G.jsx)(`p`,{role:`status`,className:`flex h-full items-center justify-center text-body text-muted-foreground`,children:`Connecting to the board`}),e&&!t?(0,G.jsx)(`p`,{role:`status`,className:`absolute top-3 left-1/2 -translate-x-1/2 rounded-xl border border-border bg-card px-3 py-1 text-body text-muted-foreground`,children:`Reconnecting to frameboard serve`}):null]})}function NQ({store:e=yl,calls:t=WE,navigate:n=F,selection:r=bD,notify:i=e=>E_.add({...e,type:`warning`,timeout:0})}={}){let a=e=>{RE(e.frames);for(let[t,n]of Object.entries(e.hashes??{}))gD(t,n);let t=r.getState(),i=t.element?e.hashes?.[t.element.frame]:void 0;if(t.page&&t.element&&i&&cD(r,t.page,{...t.element,hash:i}),e.page===null)return;let[a=``,o=``]=e.page.split(`/`);n(z(a,o))},o=(t,n,o)=>()=>{let s=()=>{},c=e.getState().history;xE([],o,()=>(s=mD(null),t().catch(e=>{throw s(),e})),{live:e,dropWhen:({history:e})=>e.undo!==c.undo||e.redo!==c.redo}).then(e=>{s(),a(e),yD(r,cH)},e=>{s(),vD(r,cH),e instanceof jl&&e.code!==`nothing-to-undo`&&i({title:n,description:e.message})})},s=t=>()=>{let{canWrite:n,history:r}=e.getState();return n&&r[t]>0},c=be([{id:`edit.undo`,label:`Undo`,group:`edit`,keys:[`$mod+KeyZ`],run:o(t.undo,`Undo skipped`,`undo`),enabled:s(`undo`),command:{label:`Undo`,icon:gr}},{id:`edit.redo`,label:`Redo`,group:`edit`,keys:[`$mod+Shift+KeyZ`],run:o(t.redo,`Redo skipped`,`redo`),enabled:s(`redo`),command:{label:`Redo`,icon:Rn}}]),l=e.subscribe((e,t)=>{(e.history!==t.history||e.canWrite!==t.canWrite)&&xe()});return()=>{l(),c()}}function PQ(){return be([{id:`palette.open`,label:`Command palette`,group:`help`,keys:[`$mod+KeyK`],run:()=>fQ(`commands`)},{id:`help.shortcuts`,label:`Keyboard shortcuts`,group:`help`,keys:[`Shift+?`],run:()=>fQ(`shortcuts`),command:{label:`Keyboard shortcuts`,icon:yt}}])}var FQ=[{choice:`system`,label:`System`},{choice:`light`,label:`Light`},{choice:`dark`,label:`Dark`}];function IQ(e=ov){let t=be([{id:`theme.toggle`,label:`Theme`,group:`view`,command:{label:`Toggle theme`,icon:Qn},run:()=>Q_(e)},...FQ.map(({choice:t,label:n})=>({id:`theme.${t}`,label:n,group:`theme`,run:()=>Z_(t,e),checked:()=>e.getState().choice===t}))]),n=e.subscribe(xe);return()=>{n(),t()}}var LQ=document.getElementById(`root`);if(!LQ)throw Error(`Missing #root element`);PN(yl,{onShow:e=>{let[t=``,n=``]=e.split(`/`);F(z(t,n)),yl.setState({focus:e})}}),Y_(ov,X_(window)),IQ(),NQ(),PQ(),De(window),(0,b.createRoot)(LQ).render((0,G.jsx)(y.StrictMode,{children:(0,G.jsx)(jQ,{})}));