@cmmd-center/forge 0.9.16 → 0.9.17

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.
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`forge-web@0.9.10`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`6c983b69-81ad-4528-a348-2ede88306ed1`,e._sentryDebugIdIdentifier=`sentry-dbid-6c983b69-81ad-4528-a348-2ede88306ed1`)}catch{}})();import{r as e}from"./rolldown-runtime-BaTzPAyU.js";import{Ba as t,Va as n,za as r}from"./Stream-D8tJNlvy.js";import{$ as i,A as a,B as o,C as s,D as c,F as l,Ft as u,H as d,I as f,L as p,M as m,N as h,O as g,Ot as _,P as v,Q as y,R as b,S as x,T as S,Ut as C,V as w,X as T,Y as E,Z as D,_ as O,_t as k,b as A,c as j,d as M,et as N,ft as P,g as F,h as I,j as L,k as R,lt as z,mt as ee,n as te,pt as B,s as V,st as H,t as ne,vt as re,w as ie,x as ae,y as oe,z as U}from"./useTriggerFocusGuards-DfUh9uvu.js";import{K as se,Mn as ce,Nn as W,S as le,U as ue,Z as G,an as de,gn as fe,h as pe,hn as K,j as me,l as he,n as ge,pn as _e,xn as ve}from"./CompositeItem-Cn5DdObI.js";var ye=W(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),be=W(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),xe=W(`chevrons-down`,[[`path`,{d:`m7 6 5 5 5-5`,key:`1lc07p`}],[`path`,{d:`m7 13 5 5 5-5`,key:`1d48rs`}]]),Se=W(`chevrons-up`,[[`path`,{d:`m17 11-5-5-5 5`,key:`e8nh98`}],[`path`,{d:`m17 18-5-5-5 5`,key:`2avn1x`}]]),Ce=W(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),we=W(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Te=W(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ee=W(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),De=W(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Oe=W(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),ke=W(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Ae=W(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),je=W(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Me=W(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Ne=W(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),q=e(n(),1),Pe=q.createContext(void 0);function J(e){let t=q.useContext(Pe);if(t===void 0&&!e)throw Error(K(47));return t}var Fe=e(C(),1),Ie={...a,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Le=class extends u{constructor(e,t,n){let r=new L;super(Re(e,r,t,n),ze(r),Ie)}setOpen=(e,t)=>{let n=t.reason===ue,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=v(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n={open:e,openChangeReason:t.reason};f(n,e,t.trigger,a()),this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),Fe.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function Re(e,t,n,r=!1){let i={...g(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i.floatingRootContext=R(t,n,r),i}function ze(e){return{popupRef:q.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:q.createRef(),beforeContentFocusGuardRef:q.createRef(),stickIfOpenTimeout:new _,triggerElements:e}}var Y=t();function Be({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=He(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),m=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),w(u,d),p(u);let{forceUnmount:g}=b(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o}),q.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),q.useImperativeHandle(e.actionsRef,()=>({unmount:g,close:()=>u.setOpen(!1,le(me))}),[g,u]);let _=d||f;return(0,Y.jsxs)(Pe.Provider,{value:u,children:[s&&(0,Y.jsx)(h,{handle:s,store:u}),_&&(0,Y.jsx)(Ue,{store:u,modal:o}),typeof t==`function`?t({payload:m}):t]})}function Ve(e){return J(!0)?(0,Y.jsx)(Be,{props:e}):(0,Y.jsx)(i,{children:(0,Y.jsx)(Be,{props:e})})}function He(e,t){let n=o((e,n)=>new Le(t,e,n));return q.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function Ue({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=E(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return U(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}var We=q.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:l,payload:u,openOnHover:f=!1,delay:p=300,closeDelay:m=0,id:h,...g}=e,_=J(!0),v=c(l)??_;if(!v)throw Error(K(74));let y=pe(h),b=v.useState(`isTriggerActive`,y),x=v.useState(`floatingRootContext`),S=v.useState(`isOpenedByTrigger`,y),C=v.useState(`triggerPopupId`,y),w=q.useRef(null),{registerTrigger:E,isMountedByThisTrigger:D}=d(y,w,v,{payload:u,disabled:a,openOnHover:f,closeDelay:m}),O=v.useState(`openChangeReason`),k=v.useState(`stickIfOpen`),j=v.useState(`openMethod`),N=v.useState(`focusManagerModal`),P=ie(x,{enabled:!a&&f&&(j!==`touch`||O!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:s(),restMs:p,delay:{close:m},triggerElementRef:w,isActiveTrigger:b,isClosing:()=>v.select(`transitionStatus`)===`ending`}),F=T(x,{stickIfOpen:k}),I=M(()=>v.select(`open`),e=>{v.set(`openMethod`,e)}),L=v.useState(`triggerProps`,D),{getButtonProps:R,buttonRef:ee}=se({disabled:a,native:o}),te={open(e){return e&&O===`trigger-press`?A.open(e):ae.open(e)}},{preFocusGuardRef:B,handlePreFocusGuardFocus:V,handleFocusTargetFocus:H}=ne(v,w),oe=G(`button`,e,{state:{disabled:a,open:S},ref:[ee,t,E,w],props:[F.reference,P,L,I,{[z]:``,id:y,"aria-haspopup":`dialog`,"aria-expanded":S,"aria-controls":C},g,R],stateAttributesMapping:te}),U=(0,Y.jsx)(q.Fragment,{children:oe},y);return D&&!N?(0,Y.jsxs)(q.Fragment,{children:[(0,Y.jsx)(re,{ref:B,onFocus:V}),U,(0,Y.jsx)(re,{ref:v.context.triggerFocusTargetRef,onFocus:H})]}):U}),Ge=q.createContext(void 0);function Ke(){let e=q.useContext(Ge);if(e===void 0)throw Error(K(45));return e}var qe=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return J().useState(`mounted`)||n?(0,Y.jsx)(Ge.Provider,{value:n,children:(0,Y.jsx)(H,{ref:t,...r})}):null}),Je=q.createContext(void 0);function Ye(){let e=q.useContext(Je);if(!e)throw Error(K(46));return e}var Xe=q.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=P,..._}=e,v=J(),b=Ke(),S=N(),C=v.useState(`floatingRootContext`),w=v.useState(`mounted`),T=v.useState(`open`),E=v.useState(`openChangeReason`),D=v.useState(`activeTriggerElement`),O=v.useState(`modal`),A=v.useState(`openMethod`),j=v.useState(`positionerElement`),M=v.useState(`instantType`),L=v.useState(`transitionStatus`),R=v.useState(`adaptiveOrigin`),z=q.useRef(null),B=ee(j),V=x({anchor:a,floatingRootContext:C,positionMethod:o,mounted:w,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:b,nodeId:S,collisionAvoidance:g,adaptiveOrigin:R}),H=C.useState(`domReferenceElement`);fe(()=>{let e=H,t=z.current;if(e&&(z.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return B(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[H,B,v]);let ne=O===!0&&E!==`trigger-hover`;te(T&&ne,A===`touch`,j,D);let re=v.useStateSetter(`positionerElement`),ie={open:T,side:V.side,align:V.align,anchorHidden:V.anchorHidden,instant:M},ae=F(e,ie,{styles:V.positionerStyles,transitionStatus:L,props:_,refs:[t,re],hidden:!w,inert:!T});return(0,Y.jsxs)(Je.Provider,{value:V,children:[w&&ne&&(0,Y.jsx)(I,{inert:k(!T),cutout:D}),(0,Y.jsx)(y,{id:S,children:ae})]})}),Ze=q.createContext(void 0);function Qe(){let[e,t]=q.useState(0),n=_e(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:q.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var $e=q.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=J(),u=Ye(),d=ge(!0)!=null,{context:f,hasClosePart:p}=Qe(),h=c.useState(`open`),g=c.useState(`openMethod`),_=c.useState(`instantType`),v=c.useState(`transitionStatus`),y=c.useState(`popupProps`),b=c.useState(`titleElementId`),x=c.useState(`descriptionElementId`),C=c.useState(`modal`),w=c.useState(`mounted`),T=c.useState(`openChangeReason`),E=c.useState(`activeTriggerElement`),k=c.useState(`floatingRootContext`),A=k.useState(`floatingId`),j=c.useState(`disabled`),M=c.useState(`openOnHover`),N=c.useState(`closeDelay`);B({open:h,ref:c.context.popupRef,onComplete(){h&&c.context.onOpenChangeComplete?.(!0)}}),S(k,{enabled:M&&!j,closeDelay:N});let P=a===void 0?l(c.context.popupRef):a,F=C!==!1&&p;c.useSyncedValue(`focusManagerModal`,F);let I=c.useStateSetter(`popupElement`),L={open:h,side:u.side,align:u.align,instant:_,transitionStatus:v},R=G(`div`,e,{state:L,ref:[t,c.context.popupRef,I],props:[y,{id:A,role:`dialog`,...m,"aria-labelledby":b,"aria-describedby":x,onKeyDown(e){d&&he.has(e.key)&&e.stopPropagation()}},O(v),s],stateAttributesMapping:oe});return(0,Y.jsx)(D,{context:k,openInteractionType:g,modal:F,disabled:!w||T===`trigger-hover`,initialFocus:P,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:de(E)?E:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Y.jsx)(Ze.Provider,{value:f,children:R})})}),et=q.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=J(),{side:c}=Ye(),l=s.useState(`instantType`),{children:u,state:d}=j({store:s,side:c,children:a}),f={activationDirection:d.activationDirection,transitioning:d.transitioning,instant:l};return G(`div`,e,{state:f,ref:t,props:[o,{children:u}],stateAttributesMapping:V})}),tt=r(),nt=Ve;function rt(e){let t=(0,tt.c)(8),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(We,{className:r,"data-slot":`popover-trigger`,...i,children:n}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function it(e){let t=(0,tt.c)(29),n,r,i,a,o,s,c,l,u;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]):({children:r,className:i,side:o,align:s,sideOffset:c,alignOffset:l,tooltipStyle:u,anchor:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u);let d=o===void 0?`bottom`:o,f=s===void 0?`center`:s,p=c===void 0?4:c,m=l===void 0?0:l,h=u!==void 0&&u,g=h&&`w-fit text-balance rounded-md text-xs shadow-md/5`,_;t[10]!==i||t[11]!==g?(_=ve(`dropdown-glass relative flex h-(--popup-height,auto) w-(--popup-width,auto) origin-(--transform-origin) rounded-lg text-popover-foreground shadow-[0_16px_40px_-18px_rgb(0_0_0/55%)] outline-none transition-[width,height,scale,opacity] has-data-[slot=calendar]:rounded-xl data-starting-style:scale-98 data-starting-style:opacity-0 dark:shadow-[0_18px_44px_-18px_rgb(0_0_0/80%)]`,g,i),t[10]=i,t[11]=g,t[12]=_):_=t[12];let v=h?`py-1 [--viewport-inline-padding:--spacing(2)]`:`not-data-transitioning:overflow-y-auto`,y;t[13]===v?y=t[14]:(y=ve(`relative size-full max-h-(--available-height) overflow-clip px-(--viewport-inline-padding) py-4 [--viewport-inline-padding:--spacing(4)] has-data-[slot=calendar]:p-2 data-instant:transition-none **:data-current:data-ending-style:opacity-0 **:data-current:data-starting-style:opacity-0 **:data-previous:data-ending-style:opacity-0 **:data-previous:data-starting-style:opacity-0 **:data-current:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-previous:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-current:opacity-100 **:data-previous:opacity-100 **:data-current:transition-opacity **:data-previous:transition-opacity`,v),t[13]=v,t[14]=y);let b;t[15]!==r||t[16]!==y?(b=(0,Y.jsx)(et,{className:y,"data-slot":`popover-viewport`,children:r}),t[15]=r,t[16]=y,t[17]=b):b=t[17];let x;t[18]!==a||t[19]!==b||t[20]!==_?(x=(0,Y.jsx)($e,{className:_,"data-slot":`popover-popup`,...a,children:b}),t[18]=a,t[19]=b,t[20]=_,t[21]=x):x=t[21];let S;return t[22]!==f||t[23]!==m||t[24]!==n||t[25]!==d||t[26]!==p||t[27]!==x?(S=(0,Y.jsx)(qe,{children:(0,Y.jsx)(Xe,{align:f,alignOffset:m,anchor:n,className:`z-50 h-(--positioner-height) w-(--positioner-width) max-w-(--available-width) transition-[top,left,right,bottom,transform] data-instant:transition-none`,"data-slot":`popover-positioner`,side:d,sideOffset:p,children:x})}),t[22]=f,t[23]=m,t[24]=n,t[25]=d,t[26]=p,t[27]=x,t[28]=S):S=t[28],S}var X={primaryColor:`#6366f1`,secondaryColor:`#8b5cf6`,accentColor:`#f59e0b`,backgroundColor:`#ffffff`,textColor:`#1f2937`,fontFamily:`Inter, sans-serif`,headingFontFamily:`Inter, sans-serif`},at={bold:{bg:`#1f2937`,accent:`#f59e0b`,text:`#ffffff`},minimal:{bg:`#ffffff`,accent:`#6366f1`,text:`#1f2937`},gradient:{bg:`#4f46e5`,accent:`#818cf8`,text:`#ffffff`},split:{bg:`#f8fafc`,accent:`#0ea5e9`,text:`#0f172a`},centered:{bg:`#fef3c7`,accent:`#d97706`,text:`#78350f`}},ot=[`bold`,`minimal`,`gradient`,`split`,`centered`];function st(e){let t=e.toLowerCase();return t.includes(`bold`)||t.includes(`sale`)||t.includes(`announcement`)?`bold`:t.includes(`minimal`)||t.includes(`clean`)||t.includes(`simple`)?`minimal`:t.includes(`gradient`)||t.includes(`modern`)||t.includes(`tech`)?`gradient`:t.includes(`split`)||t.includes(`compare`)||t.includes(`versus`)?`split`:t.includes(`warm`)||t.includes(`friendly`)||t.includes(`welcome`)?`centered`:ot[Math.floor(Math.random()*ot.length)]??`bold`}function ct(e){let t=e.replace(/^(create|make|design|generate)\s+(a|an|me)?\s*/i,``).replace(/\s*(instagram|facebook|twitter|linkedin|youtube|social media|post|story|banner|cover|thumbnail)\s*/gi,``).replace(/\s*(about|for|with|featuring)\s*/i,`|`).trim().split(`|`).map(e=>e.trim()).filter(Boolean),n=t[0]??``;if(t.length>=2)return{heading:Z(n),subtext:Z(t.slice(1).join(` `))};if(n.length>30){let e=n.split(` `),t=Math.ceil(e.length/2);return{heading:Z(e.slice(0,t).join(` `)),subtext:Z(e.slice(t).join(` `))}}return{heading:n?Z(n):`Your Title Here`,subtext:`Add your message`}}function Z(e){return e.charAt(0).toUpperCase()+e.slice(1)}function lt(e,t,n,r=X){let i=st(e),a=at[i],{heading:o,subtext:s}=ct(e),c=t>n;Math.abs(t-n);let l=[];switch(l.push({type:`rect`,left:0,top:0,width:t,height:n,fill:a.bg,selectable:!1,customId:`__bg__`,customName:`Background`}),i){case`bold`:l.push(...ut(t,n,a,o,s,r));break;case`minimal`:l.push(...dt(t,n,a,o,s,r));break;case`gradient`:l.push(...ft(t,n,a,o,s,r));break;case`split`:l.push(...pt(t,n,a,o,s,c,r));break;case`centered`:l.push(...mt(t,n,a,o,s,r))}return{objects:l}}function ut(e,t,n,r,i,a){let o=Math.min(e,t)*.08,s=Math.min(e,t)*.1,c=s*.4;return[{type:`rect`,left:0,top:0,width:e,height:t*.06,fill:n.accent,customName:`Accent Bar`},{type:`textbox`,left:o,top:t*.3,width:e-o*2,text:r.toUpperCase(),fontSize:s,fontFamily:a.headingFontFamily,fontWeight:`900`,fill:n.text,textAlign:`left`,customName:`Heading`},{type:`textbox`,left:o,top:t*.55,width:e-o*2,text:i,fontSize:c,fontFamily:a.fontFamily,fontWeight:`400`,fill:n.accent,textAlign:`left`,customName:`Subtext`},{type:`rect`,left:o,top:t*.85,width:e*.3,height:4,fill:n.accent,customName:`Accent Line`}]}function dt(e,t,n,r,i,a){let o=Math.min(e,t)*.08,s=o*.45;return[{type:`rect`,left:e*.04,top:t*.04,width:e*.92,height:t*.92,fill:`transparent`,stroke:n.accent,strokeWidth:2,customName:`Frame`},{type:`textbox`,left:e*.1,top:t*.35,width:e*.8,text:r,fontSize:o,fontFamily:a.headingFontFamily,fontWeight:`600`,fill:n.text,textAlign:`center`,customName:`Heading`},{type:`rect`,left:e*.4,top:t*.52,width:e*.2,height:2,fill:n.accent,customName:`Divider`},{type:`textbox`,left:e*.15,top:t*.58,width:e*.7,text:i,fontSize:s,fontFamily:a.fontFamily,fontWeight:`400`,fill:`#6b7280`,textAlign:`center`,customName:`Subtext`}]}function ft(e,t,n,r,i,a){let o=Math.min(e,t)*.09,s=o*.4;return[{type:`rect`,left:0,top:t*.6,width:e,height:t*.4,fill:`rgba(0,0,0,0.3)`,customName:`Overlay`},{type:`ellipse`,left:e*.7,top:-t*.15,rx:e*.25,ry:e*.25,fill:n.accent,opacity:.3,customName:`Deco Circle`},{type:`textbox`,left:e*.08,top:t*.35,width:e*.84,text:r,fontSize:o,fontFamily:a.headingFontFamily,fontWeight:`700`,fill:n.text,textAlign:`center`,customName:`Heading`},{type:`textbox`,left:e*.12,top:t*.65,width:e*.76,text:i,fontSize:s,fontFamily:a.fontFamily,fontWeight:`400`,fill:`rgba(255,255,255,0.85)`,textAlign:`center`,customName:`Subtext`}]}function pt(e,t,n,r,i,a,o){let s=Math.min(e,t)*.08,c=s*.45;return a?[{type:`rect`,left:0,top:0,width:e*.45,height:t,fill:n.accent,customName:`Color Panel`},{type:`textbox`,left:e*.52,top:t*.3,width:e*.42,text:r,fontSize:s,fontFamily:o.headingFontFamily,fontWeight:`700`,fill:n.text,textAlign:`left`,customName:`Heading`},{type:`textbox`,left:e*.52,top:t*.55,width:e*.42,text:i,fontSize:c,fontFamily:o.fontFamily,fontWeight:`400`,fill:`#64748b`,textAlign:`left`,customName:`Subtext`}]:[{type:`rect`,left:0,top:0,width:e,height:t*.45,fill:n.accent,customName:`Color Panel`},{type:`textbox`,left:e*.08,top:t*.52,width:e*.84,text:r,fontSize:s,fontFamily:o.headingFontFamily,fontWeight:`700`,fill:n.text,textAlign:`center`,customName:`Heading`},{type:`textbox`,left:e*.12,top:t*.72,width:e*.76,text:i,fontSize:c,fontFamily:o.fontFamily,fontWeight:`400`,fill:`#64748b`,textAlign:`center`,customName:`Subtext`}]}function mt(e,t,n,r,i,a){let o=Math.min(e,t)*.09,s=o*.4;return[{type:`rect`,left:e*.1,top:t*.15,width:e*.8,height:t*.7,fill:`rgba(255,255,255,0.7)`,rx:20,ry:20,customName:`Card`},{type:`textbox`,left:e*.15,top:t*.3,width:e*.7,text:r,fontSize:o,fontFamily:a.headingFontFamily,fontWeight:`700`,fill:n.text,textAlign:`center`,customName:`Heading`},{type:`textbox`,left:e*.18,top:t*.55,width:e*.64,text:i,fontSize:s,fontFamily:a.fontFamily,fontWeight:`400`,fill:n.text,textAlign:`center`,opacity:.7,customName:`Subtext`},{type:`rect`,left:e*.3,top:t*.72,width:e*.4,height:Math.min(e,t)*.07,fill:n.accent,rx:8,ry:8,customName:`CTA Button`},{type:`textbox`,left:e*.3,top:t*.725,width:e*.4,text:`Learn More`,fontSize:s*.9,fontFamily:a.fontFamily,fontWeight:`600`,fill:`#ffffff`,textAlign:`center`,customName:`CTA Text`}]}var ht=[{id:`ig-post-bold`,name:`Bold Announcement`,category:`social`,presetId:`instagram-post`,style:`bold`,description:`High-impact Instagram post with bold typography`,previewPrompt:`New Product Launch`},{id:`ig-post-minimal`,name:`Clean & Minimal`,category:`social`,presetId:`instagram-post`,style:`minimal`,description:`Minimalist Instagram post with elegant framing`,previewPrompt:`Mindful Living`},{id:`ig-story-gradient`,name:`Gradient Story`,category:`social`,presetId:`instagram-story`,style:`gradient`,description:`Modern gradient Instagram story`,previewPrompt:`Summer Vibes`},{id:`fb-cover-split`,name:`Split Cover`,category:`social`,presetId:`facebook-cover`,style:`split`,description:`Two-tone Facebook cover photo`,previewPrompt:`Welcome to Our Community`},{id:`linkedin-minimal`,name:`Professional Banner`,category:`business`,presetId:`linkedin-banner`,style:`minimal`,description:`Clean LinkedIn banner for professionals`,previewPrompt:`Innovation & Strategy`},{id:`twitter-bold`,name:`Tweet Graphic`,category:`social`,presetId:`twitter-post`,style:`bold`,description:`Eye-catching Twitter/X post graphic`,previewPrompt:`Breaking News`},{id:`yt-gradient`,name:`YouTube Thumbnail`,category:`social`,presetId:`youtube-thumbnail`,style:`gradient`,description:`Vibrant YouTube thumbnail`,previewPrompt:`Top 10 Tips`},{id:`presentation-centered`,name:`Title Slide`,category:`presentation`,presetId:`presentation`,style:`centered`,description:`Warm presentation title slide`,previewPrompt:`Quarterly Review`},{id:`bcard-minimal`,name:`Business Card`,category:`business`,presetId:`business-card`,style:`minimal`,description:`Elegant business card layout`,previewPrompt:`Jane Smith | Designer`},{id:`invoice-split`,name:`Invoice Header`,category:`business`,presetId:`invoice`,style:`split`,description:`Professional invoice header layout`,previewPrompt:`Invoice #1234`},{id:`sale-bold`,name:`Flash Sale`,category:`marketing`,presetId:`instagram-post`,style:`bold`,description:`High-energy sale promotion post`,previewPrompt:`50% Off Everything`},{id:`launch-gradient`,name:`Product Launch`,category:`marketing`,presetId:`instagram-post`,style:`gradient`,description:`Modern product launch announcement`,previewPrompt:`Introducing Our New Product`}];function gt(){let e=new Map;for(let t of ht){let n=e.get(t.category)??[];n.push(t),e.set(t.category,n)}return e}var _t=`forge:canvas-state:v1`;function vt(){if(typeof window>`u`)return{};try{let e=localStorage.getItem(_t);if(!e)return{};let t=JSON.parse(e),n={savedDesigns:t.savedDesigns??{},artboardPresetId:t.artboardPresetId??null,activeTool:t.activeTool??`select`};return t.brandKit&&(n.brandKit=t.brandKit),n}catch{return{}}}function Q(e){if(!(typeof window>`u`))try{let t={savedDesigns:e.savedDesigns,artboardPresetId:e.artboardPresetId,activeTool:e.activeTool,brandKit:e.brandKit};localStorage.setItem(_t,JSON.stringify(t))}catch{}}var $=vt(),yt={activeTool:$.activeTool??`select`,artboardPresetId:$.artboardPresetId??`instagram-post`,artboardWidth:1080,artboardHeight:1080,selectedObjectIds:[],selectedObjectProperties:null,propertiesPanelOpen:!1,historyStack:[],historyIndex:-1,layers:[],zoomLevel:1,savedDesigns:$.savedDesigns??{},brandKit:$.brandKit??X,pendingGeneratePrompt:null},bt=ce()((e,t)=>({...yt,setActiveTool:n=>{e({activeTool:n}),Q(t())},setArtboard:(n,r,i)=>{e({artboardPresetId:n,artboardWidth:r,artboardHeight:i}),Q(t())},setSelectedObjects:(t,n)=>{e({selectedObjectIds:t,selectedObjectProperties:n,propertiesPanelOpen:t.length>0})},clearSelection:()=>{e({selectedObjectIds:[],selectedObjectProperties:null})},setPropertiesPanelOpen:t=>{e({propertiesPanelOpen:t})},pushHistorySnapshot:t=>{e(e=>{let n=[...e.historyStack.slice(0,e.historyIndex+1),t].slice(-50);return{historyStack:n,historyIndex:n.length-1}})},undo:()=>{let n=t();if(n.historyIndex<=0)return null;let r=n.historyIndex-1;return e({historyIndex:r}),n.historyStack[r]??null},redo:()=>{let n=t();if(n.historyIndex>=n.historyStack.length-1)return null;let r=n.historyIndex+1;return e({historyIndex:r}),n.historyStack[r]??null},setLayers:t=>{e({layers:t})},setZoomLevel:t=>{e({zoomLevel:t})},saveDesign:(n,r,i)=>{e(e=>({savedDesigns:{...e.savedDesigns,[n]:{json:i,name:r,updatedAt:new Date().toISOString()}}})),Q(t())},loadDesign:e=>t().savedDesigns[e]?.json??null,deleteDesign:n=>{e(e=>{let{[n]:t,...r}=e.savedDesigns;return{savedDesigns:r}}),Q(t())},resetHistory:()=>{e({historyStack:[],historyIndex:-1})},setBrandKit:n=>{e({brandKit:n}),Q(t())},updateBrandKit:n=>{e(e=>({brandKit:{...e.brandKit,...n}})),Q(t())},requestCanvasGenerate:t=>{e({pendingGeneratePrompt:t})},consumePendingGenerate:()=>{let n=t().pendingGeneratePrompt;return n&&e({pendingGeneratePrompt:null}),n}}));export{ye as C,be as S,Te as _,gt as a,Se as b,rt as c,je as d,Ae as f,Ee as g,De as h,lt as i,Ne as l,Oe as m,ht as n,nt as o,ke as p,X as r,it as s,bt as t,Me as u,we as v,xe as x,Ce as y};
2
- //# sourceMappingURL=canvasStateStore-Dlm4tanv.js.map
1
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`forge-web@0.9.10`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`6c983b69-81ad-4528-a348-2ede88306ed1`,e._sentryDebugIdIdentifier=`sentry-dbid-6c983b69-81ad-4528-a348-2ede88306ed1`)}catch{}})();import{r as e}from"./rolldown-runtime-BaTzPAyU.js";import{Ba as t,Va as n,za as r}from"./Stream-D8tJNlvy.js";import{$ as i,A as a,B as o,C as s,D as c,F as l,Ft as u,H as d,I as f,L as p,M as m,N as h,O as g,Ot as _,P as v,Q as y,R as b,S as x,T as S,Ut as C,V as w,X as T,Y as E,Z as D,_ as O,_t as k,b as A,c as j,d as M,et as N,ft as P,g as F,h as I,j as L,k as R,lt as z,mt as ee,n as te,pt as B,s as V,st as H,t as ne,vt as re,w as ie,x as ae,y as oe,z as U}from"./useTriggerFocusGuards-mvO6ygs-.js";import{K as se,Mn as ce,Nn as W,S as le,U as ue,Z as G,an as de,gn as fe,h as pe,hn as K,j as me,l as he,n as ge,pn as _e,xn as ve}from"./CompositeItem-Bsi2e5qV.js";var ye=W(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),be=W(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),xe=W(`chevrons-down`,[[`path`,{d:`m7 6 5 5 5-5`,key:`1lc07p`}],[`path`,{d:`m7 13 5 5 5-5`,key:`1d48rs`}]]),Se=W(`chevrons-up`,[[`path`,{d:`m17 11-5-5-5 5`,key:`e8nh98`}],[`path`,{d:`m17 18-5-5-5 5`,key:`2avn1x`}]]),Ce=W(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),we=W(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Te=W(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ee=W(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),De=W(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Oe=W(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),ke=W(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Ae=W(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),je=W(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Me=W(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Ne=W(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),q=e(n(),1),Pe=q.createContext(void 0);function J(e){let t=q.useContext(Pe);if(t===void 0&&!e)throw Error(K(47));return t}var Fe=e(C(),1),Ie={...a,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Le=class extends u{constructor(e,t,n){let r=new L;super(Re(e,r,t,n),ze(r),Ie)}setOpen=(e,t)=>{let n=t.reason===ue,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=v(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n={open:e,openChangeReason:t.reason};f(n,e,t.trigger,a()),this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),Fe.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function Re(e,t,n,r=!1){let i={...g(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i.floatingRootContext=R(t,n,r),i}function ze(e){return{popupRef:q.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:q.createRef(),beforeContentFocusGuardRef:q.createRef(),stickIfOpenTimeout:new _,triggerElements:e}}var Y=t();function Be({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=He(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),m=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),w(u,d),p(u);let{forceUnmount:g}=b(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o}),q.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),q.useImperativeHandle(e.actionsRef,()=>({unmount:g,close:()=>u.setOpen(!1,le(me))}),[g,u]);let _=d||f;return(0,Y.jsxs)(Pe.Provider,{value:u,children:[s&&(0,Y.jsx)(h,{handle:s,store:u}),_&&(0,Y.jsx)(Ue,{store:u,modal:o}),typeof t==`function`?t({payload:m}):t]})}function Ve(e){return J(!0)?(0,Y.jsx)(Be,{props:e}):(0,Y.jsx)(i,{children:(0,Y.jsx)(Be,{props:e})})}function He(e,t){let n=o((e,n)=>new Le(t,e,n));return q.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function Ue({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=E(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return U(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}var We=q.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:l,payload:u,openOnHover:f=!1,delay:p=300,closeDelay:m=0,id:h,...g}=e,_=J(!0),v=c(l)??_;if(!v)throw Error(K(74));let y=pe(h),b=v.useState(`isTriggerActive`,y),x=v.useState(`floatingRootContext`),S=v.useState(`isOpenedByTrigger`,y),C=v.useState(`triggerPopupId`,y),w=q.useRef(null),{registerTrigger:E,isMountedByThisTrigger:D}=d(y,w,v,{payload:u,disabled:a,openOnHover:f,closeDelay:m}),O=v.useState(`openChangeReason`),k=v.useState(`stickIfOpen`),j=v.useState(`openMethod`),N=v.useState(`focusManagerModal`),P=ie(x,{enabled:!a&&f&&(j!==`touch`||O!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:s(),restMs:p,delay:{close:m},triggerElementRef:w,isActiveTrigger:b,isClosing:()=>v.select(`transitionStatus`)===`ending`}),F=T(x,{stickIfOpen:k}),I=M(()=>v.select(`open`),e=>{v.set(`openMethod`,e)}),L=v.useState(`triggerProps`,D),{getButtonProps:R,buttonRef:ee}=se({disabled:a,native:o}),te={open(e){return e&&O===`trigger-press`?A.open(e):ae.open(e)}},{preFocusGuardRef:B,handlePreFocusGuardFocus:V,handleFocusTargetFocus:H}=ne(v,w),oe=G(`button`,e,{state:{disabled:a,open:S},ref:[ee,t,E,w],props:[F.reference,P,L,I,{[z]:``,id:y,"aria-haspopup":`dialog`,"aria-expanded":S,"aria-controls":C},g,R],stateAttributesMapping:te}),U=(0,Y.jsx)(q.Fragment,{children:oe},y);return D&&!N?(0,Y.jsxs)(q.Fragment,{children:[(0,Y.jsx)(re,{ref:B,onFocus:V}),U,(0,Y.jsx)(re,{ref:v.context.triggerFocusTargetRef,onFocus:H})]}):U}),Ge=q.createContext(void 0);function Ke(){let e=q.useContext(Ge);if(e===void 0)throw Error(K(45));return e}var qe=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return J().useState(`mounted`)||n?(0,Y.jsx)(Ge.Provider,{value:n,children:(0,Y.jsx)(H,{ref:t,...r})}):null}),Je=q.createContext(void 0);function Ye(){let e=q.useContext(Je);if(!e)throw Error(K(46));return e}var Xe=q.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=P,..._}=e,v=J(),b=Ke(),S=N(),C=v.useState(`floatingRootContext`),w=v.useState(`mounted`),T=v.useState(`open`),E=v.useState(`openChangeReason`),D=v.useState(`activeTriggerElement`),O=v.useState(`modal`),A=v.useState(`openMethod`),j=v.useState(`positionerElement`),M=v.useState(`instantType`),L=v.useState(`transitionStatus`),R=v.useState(`adaptiveOrigin`),z=q.useRef(null),B=ee(j),V=x({anchor:a,floatingRootContext:C,positionMethod:o,mounted:w,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:b,nodeId:S,collisionAvoidance:g,adaptiveOrigin:R}),H=C.useState(`domReferenceElement`);fe(()=>{let e=H,t=z.current;if(e&&(z.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return B(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[H,B,v]);let ne=O===!0&&E!==`trigger-hover`;te(T&&ne,A===`touch`,j,D);let re=v.useStateSetter(`positionerElement`),ie={open:T,side:V.side,align:V.align,anchorHidden:V.anchorHidden,instant:M},ae=F(e,ie,{styles:V.positionerStyles,transitionStatus:L,props:_,refs:[t,re],hidden:!w,inert:!T});return(0,Y.jsxs)(Je.Provider,{value:V,children:[w&&ne&&(0,Y.jsx)(I,{inert:k(!T),cutout:D}),(0,Y.jsx)(y,{id:S,children:ae})]})}),Ze=q.createContext(void 0);function Qe(){let[e,t]=q.useState(0),n=_e(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:q.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var $e=q.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=J(),u=Ye(),d=ge(!0)!=null,{context:f,hasClosePart:p}=Qe(),h=c.useState(`open`),g=c.useState(`openMethod`),_=c.useState(`instantType`),v=c.useState(`transitionStatus`),y=c.useState(`popupProps`),b=c.useState(`titleElementId`),x=c.useState(`descriptionElementId`),C=c.useState(`modal`),w=c.useState(`mounted`),T=c.useState(`openChangeReason`),E=c.useState(`activeTriggerElement`),k=c.useState(`floatingRootContext`),A=k.useState(`floatingId`),j=c.useState(`disabled`),M=c.useState(`openOnHover`),N=c.useState(`closeDelay`);B({open:h,ref:c.context.popupRef,onComplete(){h&&c.context.onOpenChangeComplete?.(!0)}}),S(k,{enabled:M&&!j,closeDelay:N});let P=a===void 0?l(c.context.popupRef):a,F=C!==!1&&p;c.useSyncedValue(`focusManagerModal`,F);let I=c.useStateSetter(`popupElement`),L={open:h,side:u.side,align:u.align,instant:_,transitionStatus:v},R=G(`div`,e,{state:L,ref:[t,c.context.popupRef,I],props:[y,{id:A,role:`dialog`,...m,"aria-labelledby":b,"aria-describedby":x,onKeyDown(e){d&&he.has(e.key)&&e.stopPropagation()}},O(v),s],stateAttributesMapping:oe});return(0,Y.jsx)(D,{context:k,openInteractionType:g,modal:F,disabled:!w||T===`trigger-hover`,initialFocus:P,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:de(E)?E:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Y.jsx)(Ze.Provider,{value:f,children:R})})}),et=q.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=J(),{side:c}=Ye(),l=s.useState(`instantType`),{children:u,state:d}=j({store:s,side:c,children:a}),f={activationDirection:d.activationDirection,transitioning:d.transitioning,instant:l};return G(`div`,e,{state:f,ref:t,props:[o,{children:u}],stateAttributesMapping:V})}),tt=r(),nt=Ve;function rt(e){let t=(0,tt.c)(8),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,Y.jsx)(We,{className:r,"data-slot":`popover-trigger`,...i,children:n}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function it(e){let t=(0,tt.c)(29),n,r,i,a,o,s,c,l,u;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]):({children:r,className:i,side:o,align:s,sideOffset:c,alignOffset:l,tooltipStyle:u,anchor:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u);let d=o===void 0?`bottom`:o,f=s===void 0?`center`:s,p=c===void 0?4:c,m=l===void 0?0:l,h=u!==void 0&&u,g=h&&`w-fit text-balance rounded-md text-xs shadow-md/5`,_;t[10]!==i||t[11]!==g?(_=ve(`dropdown-glass relative flex h-(--popup-height,auto) w-(--popup-width,auto) origin-(--transform-origin) rounded-lg text-popover-foreground shadow-[0_16px_40px_-18px_rgb(0_0_0/55%)] outline-none transition-[width,height,scale,opacity] has-data-[slot=calendar]:rounded-xl data-starting-style:scale-98 data-starting-style:opacity-0 dark:shadow-[0_18px_44px_-18px_rgb(0_0_0/80%)]`,g,i),t[10]=i,t[11]=g,t[12]=_):_=t[12];let v=h?`py-1 [--viewport-inline-padding:--spacing(2)]`:`not-data-transitioning:overflow-y-auto`,y;t[13]===v?y=t[14]:(y=ve(`relative size-full max-h-(--available-height) overflow-clip px-(--viewport-inline-padding) py-4 [--viewport-inline-padding:--spacing(4)] has-data-[slot=calendar]:p-2 data-instant:transition-none **:data-current:data-ending-style:opacity-0 **:data-current:data-starting-style:opacity-0 **:data-previous:data-ending-style:opacity-0 **:data-previous:data-starting-style:opacity-0 **:data-current:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-previous:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-current:opacity-100 **:data-previous:opacity-100 **:data-current:transition-opacity **:data-previous:transition-opacity`,v),t[13]=v,t[14]=y);let b;t[15]!==r||t[16]!==y?(b=(0,Y.jsx)(et,{className:y,"data-slot":`popover-viewport`,children:r}),t[15]=r,t[16]=y,t[17]=b):b=t[17];let x;t[18]!==a||t[19]!==b||t[20]!==_?(x=(0,Y.jsx)($e,{className:_,"data-slot":`popover-popup`,...a,children:b}),t[18]=a,t[19]=b,t[20]=_,t[21]=x):x=t[21];let S;return t[22]!==f||t[23]!==m||t[24]!==n||t[25]!==d||t[26]!==p||t[27]!==x?(S=(0,Y.jsx)(qe,{children:(0,Y.jsx)(Xe,{align:f,alignOffset:m,anchor:n,className:`z-50 h-(--positioner-height) w-(--positioner-width) max-w-(--available-width) transition-[top,left,right,bottom,transform] data-instant:transition-none`,"data-slot":`popover-positioner`,side:d,sideOffset:p,children:x})}),t[22]=f,t[23]=m,t[24]=n,t[25]=d,t[26]=p,t[27]=x,t[28]=S):S=t[28],S}var X={primaryColor:`#6366f1`,secondaryColor:`#8b5cf6`,accentColor:`#f59e0b`,backgroundColor:`#ffffff`,textColor:`#1f2937`,fontFamily:`Inter, sans-serif`,headingFontFamily:`Inter, sans-serif`},at={bold:{bg:`#1f2937`,accent:`#f59e0b`,text:`#ffffff`},minimal:{bg:`#ffffff`,accent:`#6366f1`,text:`#1f2937`},gradient:{bg:`#4f46e5`,accent:`#818cf8`,text:`#ffffff`},split:{bg:`#f8fafc`,accent:`#0ea5e9`,text:`#0f172a`},centered:{bg:`#fef3c7`,accent:`#d97706`,text:`#78350f`}},ot=[`bold`,`minimal`,`gradient`,`split`,`centered`];function st(e){let t=e.toLowerCase();return t.includes(`bold`)||t.includes(`sale`)||t.includes(`announcement`)?`bold`:t.includes(`minimal`)||t.includes(`clean`)||t.includes(`simple`)?`minimal`:t.includes(`gradient`)||t.includes(`modern`)||t.includes(`tech`)?`gradient`:t.includes(`split`)||t.includes(`compare`)||t.includes(`versus`)?`split`:t.includes(`warm`)||t.includes(`friendly`)||t.includes(`welcome`)?`centered`:ot[Math.floor(Math.random()*ot.length)]??`bold`}function ct(e){let t=e.replace(/^(create|make|design|generate)\s+(a|an|me)?\s*/i,``).replace(/\s*(instagram|facebook|twitter|linkedin|youtube|social media|post|story|banner|cover|thumbnail)\s*/gi,``).replace(/\s*(about|for|with|featuring)\s*/i,`|`).trim().split(`|`).map(e=>e.trim()).filter(Boolean),n=t[0]??``;if(t.length>=2)return{heading:Z(n),subtext:Z(t.slice(1).join(` `))};if(n.length>30){let e=n.split(` `),t=Math.ceil(e.length/2);return{heading:Z(e.slice(0,t).join(` `)),subtext:Z(e.slice(t).join(` `))}}return{heading:n?Z(n):`Your Title Here`,subtext:`Add your message`}}function Z(e){return e.charAt(0).toUpperCase()+e.slice(1)}function lt(e,t,n,r=X){let i=st(e),a=at[i],{heading:o,subtext:s}=ct(e),c=t>n;Math.abs(t-n);let l=[];switch(l.push({type:`rect`,left:0,top:0,width:t,height:n,fill:a.bg,selectable:!1,customId:`__bg__`,customName:`Background`}),i){case`bold`:l.push(...ut(t,n,a,o,s,r));break;case`minimal`:l.push(...dt(t,n,a,o,s,r));break;case`gradient`:l.push(...ft(t,n,a,o,s,r));break;case`split`:l.push(...pt(t,n,a,o,s,c,r));break;case`centered`:l.push(...mt(t,n,a,o,s,r))}return{objects:l}}function ut(e,t,n,r,i,a){let o=Math.min(e,t)*.08,s=Math.min(e,t)*.1,c=s*.4;return[{type:`rect`,left:0,top:0,width:e,height:t*.06,fill:n.accent,customName:`Accent Bar`},{type:`textbox`,left:o,top:t*.3,width:e-o*2,text:r.toUpperCase(),fontSize:s,fontFamily:a.headingFontFamily,fontWeight:`900`,fill:n.text,textAlign:`left`,customName:`Heading`},{type:`textbox`,left:o,top:t*.55,width:e-o*2,text:i,fontSize:c,fontFamily:a.fontFamily,fontWeight:`400`,fill:n.accent,textAlign:`left`,customName:`Subtext`},{type:`rect`,left:o,top:t*.85,width:e*.3,height:4,fill:n.accent,customName:`Accent Line`}]}function dt(e,t,n,r,i,a){let o=Math.min(e,t)*.08,s=o*.45;return[{type:`rect`,left:e*.04,top:t*.04,width:e*.92,height:t*.92,fill:`transparent`,stroke:n.accent,strokeWidth:2,customName:`Frame`},{type:`textbox`,left:e*.1,top:t*.35,width:e*.8,text:r,fontSize:o,fontFamily:a.headingFontFamily,fontWeight:`600`,fill:n.text,textAlign:`center`,customName:`Heading`},{type:`rect`,left:e*.4,top:t*.52,width:e*.2,height:2,fill:n.accent,customName:`Divider`},{type:`textbox`,left:e*.15,top:t*.58,width:e*.7,text:i,fontSize:s,fontFamily:a.fontFamily,fontWeight:`400`,fill:`#6b7280`,textAlign:`center`,customName:`Subtext`}]}function ft(e,t,n,r,i,a){let o=Math.min(e,t)*.09,s=o*.4;return[{type:`rect`,left:0,top:t*.6,width:e,height:t*.4,fill:`rgba(0,0,0,0.3)`,customName:`Overlay`},{type:`ellipse`,left:e*.7,top:-t*.15,rx:e*.25,ry:e*.25,fill:n.accent,opacity:.3,customName:`Deco Circle`},{type:`textbox`,left:e*.08,top:t*.35,width:e*.84,text:r,fontSize:o,fontFamily:a.headingFontFamily,fontWeight:`700`,fill:n.text,textAlign:`center`,customName:`Heading`},{type:`textbox`,left:e*.12,top:t*.65,width:e*.76,text:i,fontSize:s,fontFamily:a.fontFamily,fontWeight:`400`,fill:`rgba(255,255,255,0.85)`,textAlign:`center`,customName:`Subtext`}]}function pt(e,t,n,r,i,a,o){let s=Math.min(e,t)*.08,c=s*.45;return a?[{type:`rect`,left:0,top:0,width:e*.45,height:t,fill:n.accent,customName:`Color Panel`},{type:`textbox`,left:e*.52,top:t*.3,width:e*.42,text:r,fontSize:s,fontFamily:o.headingFontFamily,fontWeight:`700`,fill:n.text,textAlign:`left`,customName:`Heading`},{type:`textbox`,left:e*.52,top:t*.55,width:e*.42,text:i,fontSize:c,fontFamily:o.fontFamily,fontWeight:`400`,fill:`#64748b`,textAlign:`left`,customName:`Subtext`}]:[{type:`rect`,left:0,top:0,width:e,height:t*.45,fill:n.accent,customName:`Color Panel`},{type:`textbox`,left:e*.08,top:t*.52,width:e*.84,text:r,fontSize:s,fontFamily:o.headingFontFamily,fontWeight:`700`,fill:n.text,textAlign:`center`,customName:`Heading`},{type:`textbox`,left:e*.12,top:t*.72,width:e*.76,text:i,fontSize:c,fontFamily:o.fontFamily,fontWeight:`400`,fill:`#64748b`,textAlign:`center`,customName:`Subtext`}]}function mt(e,t,n,r,i,a){let o=Math.min(e,t)*.09,s=o*.4;return[{type:`rect`,left:e*.1,top:t*.15,width:e*.8,height:t*.7,fill:`rgba(255,255,255,0.7)`,rx:20,ry:20,customName:`Card`},{type:`textbox`,left:e*.15,top:t*.3,width:e*.7,text:r,fontSize:o,fontFamily:a.headingFontFamily,fontWeight:`700`,fill:n.text,textAlign:`center`,customName:`Heading`},{type:`textbox`,left:e*.18,top:t*.55,width:e*.64,text:i,fontSize:s,fontFamily:a.fontFamily,fontWeight:`400`,fill:n.text,textAlign:`center`,opacity:.7,customName:`Subtext`},{type:`rect`,left:e*.3,top:t*.72,width:e*.4,height:Math.min(e,t)*.07,fill:n.accent,rx:8,ry:8,customName:`CTA Button`},{type:`textbox`,left:e*.3,top:t*.725,width:e*.4,text:`Learn More`,fontSize:s*.9,fontFamily:a.fontFamily,fontWeight:`600`,fill:`#ffffff`,textAlign:`center`,customName:`CTA Text`}]}var ht=[{id:`ig-post-bold`,name:`Bold Announcement`,category:`social`,presetId:`instagram-post`,style:`bold`,description:`High-impact Instagram post with bold typography`,previewPrompt:`New Product Launch`},{id:`ig-post-minimal`,name:`Clean & Minimal`,category:`social`,presetId:`instagram-post`,style:`minimal`,description:`Minimalist Instagram post with elegant framing`,previewPrompt:`Mindful Living`},{id:`ig-story-gradient`,name:`Gradient Story`,category:`social`,presetId:`instagram-story`,style:`gradient`,description:`Modern gradient Instagram story`,previewPrompt:`Summer Vibes`},{id:`fb-cover-split`,name:`Split Cover`,category:`social`,presetId:`facebook-cover`,style:`split`,description:`Two-tone Facebook cover photo`,previewPrompt:`Welcome to Our Community`},{id:`linkedin-minimal`,name:`Professional Banner`,category:`business`,presetId:`linkedin-banner`,style:`minimal`,description:`Clean LinkedIn banner for professionals`,previewPrompt:`Innovation & Strategy`},{id:`twitter-bold`,name:`Tweet Graphic`,category:`social`,presetId:`twitter-post`,style:`bold`,description:`Eye-catching Twitter/X post graphic`,previewPrompt:`Breaking News`},{id:`yt-gradient`,name:`YouTube Thumbnail`,category:`social`,presetId:`youtube-thumbnail`,style:`gradient`,description:`Vibrant YouTube thumbnail`,previewPrompt:`Top 10 Tips`},{id:`presentation-centered`,name:`Title Slide`,category:`presentation`,presetId:`presentation`,style:`centered`,description:`Warm presentation title slide`,previewPrompt:`Quarterly Review`},{id:`bcard-minimal`,name:`Business Card`,category:`business`,presetId:`business-card`,style:`minimal`,description:`Elegant business card layout`,previewPrompt:`Jane Smith | Designer`},{id:`invoice-split`,name:`Invoice Header`,category:`business`,presetId:`invoice`,style:`split`,description:`Professional invoice header layout`,previewPrompt:`Invoice #1234`},{id:`sale-bold`,name:`Flash Sale`,category:`marketing`,presetId:`instagram-post`,style:`bold`,description:`High-energy sale promotion post`,previewPrompt:`50% Off Everything`},{id:`launch-gradient`,name:`Product Launch`,category:`marketing`,presetId:`instagram-post`,style:`gradient`,description:`Modern product launch announcement`,previewPrompt:`Introducing Our New Product`}];function gt(){let e=new Map;for(let t of ht){let n=e.get(t.category)??[];n.push(t),e.set(t.category,n)}return e}var _t=`forge:canvas-state:v1`;function vt(){if(typeof window>`u`)return{};try{let e=localStorage.getItem(_t);if(!e)return{};let t=JSON.parse(e),n={savedDesigns:t.savedDesigns??{},artboardPresetId:t.artboardPresetId??null,activeTool:t.activeTool??`select`};return t.brandKit&&(n.brandKit=t.brandKit),n}catch{return{}}}function Q(e){if(!(typeof window>`u`))try{let t={savedDesigns:e.savedDesigns,artboardPresetId:e.artboardPresetId,activeTool:e.activeTool,brandKit:e.brandKit};localStorage.setItem(_t,JSON.stringify(t))}catch{}}var $=vt(),yt={activeTool:$.activeTool??`select`,artboardPresetId:$.artboardPresetId??`instagram-post`,artboardWidth:1080,artboardHeight:1080,selectedObjectIds:[],selectedObjectProperties:null,propertiesPanelOpen:!1,historyStack:[],historyIndex:-1,layers:[],zoomLevel:1,savedDesigns:$.savedDesigns??{},brandKit:$.brandKit??X,pendingGeneratePrompt:null},bt=ce()((e,t)=>({...yt,setActiveTool:n=>{e({activeTool:n}),Q(t())},setArtboard:(n,r,i)=>{e({artboardPresetId:n,artboardWidth:r,artboardHeight:i}),Q(t())},setSelectedObjects:(t,n)=>{e({selectedObjectIds:t,selectedObjectProperties:n,propertiesPanelOpen:t.length>0})},clearSelection:()=>{e({selectedObjectIds:[],selectedObjectProperties:null})},setPropertiesPanelOpen:t=>{e({propertiesPanelOpen:t})},pushHistorySnapshot:t=>{e(e=>{let n=[...e.historyStack.slice(0,e.historyIndex+1),t].slice(-50);return{historyStack:n,historyIndex:n.length-1}})},undo:()=>{let n=t();if(n.historyIndex<=0)return null;let r=n.historyIndex-1;return e({historyIndex:r}),n.historyStack[r]??null},redo:()=>{let n=t();if(n.historyIndex>=n.historyStack.length-1)return null;let r=n.historyIndex+1;return e({historyIndex:r}),n.historyStack[r]??null},setLayers:t=>{e({layers:t})},setZoomLevel:t=>{e({zoomLevel:t})},saveDesign:(n,r,i)=>{e(e=>({savedDesigns:{...e.savedDesigns,[n]:{json:i,name:r,updatedAt:new Date().toISOString()}}})),Q(t())},loadDesign:e=>t().savedDesigns[e]?.json??null,deleteDesign:n=>{e(e=>{let{[n]:t,...r}=e.savedDesigns;return{savedDesigns:r}}),Q(t())},resetHistory:()=>{e({historyStack:[],historyIndex:-1})},setBrandKit:n=>{e({brandKit:n}),Q(t())},updateBrandKit:n=>{e(e=>({brandKit:{...e.brandKit,...n}})),Q(t())},requestCanvasGenerate:t=>{e({pendingGeneratePrompt:t})},consumePendingGenerate:()=>{let n=t().pendingGeneratePrompt;return n&&e({pendingGeneratePrompt:null}),n}}));export{ye as C,be as S,Te as _,gt as a,Se as b,rt as c,je as d,Ae as f,Ee as g,De as h,lt as i,Ne as l,Oe as m,ht as n,nt as o,ke as p,X as r,it as s,bt as t,Me as u,we as v,xe as x,Ce as y};
2
+ //# sourceMappingURL=canvasStateStore-qioLqOoT.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`forge-web@0.9.10`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`176ca5d7-5fd7-4459-8664-3bdf6e6c5813`,e._sentryDebugIdIdentifier=`sentry-dbid-176ca5d7-5fd7-4459-8664-3bdf6e6c5813`)}catch{}})();import{n as e,r as t}from"./rolldown-runtime-BaTzPAyU.js";import{Va as n}from"./Stream-D8tJNlvy.js";import{a as r,c as i,l as a,n as o,o as s,r as c,s as l}from"./atomRegistry-Bz2MHqst.js";import{dt as ee,wn as te}from"./src-DljvAdHI.js";var u=t(n(),1),d=new WeakMap;function ne(e,t){let n=d.get(e);n===void 0&&(n=new WeakMap,d.set(e,n));let i=n.get(t);if(i!==void 0)return i;let a={subscribe(n){return e.subscribe(t,n)},snapshot(){return e.get(t)},getServerSnapshot(){return r(t,e)}};return n.set(t,a),a}function f(e,t){let n=ne(e,t);return u.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}var p=(e,t)=>{let n=u.useContext(c);return t?f(n,u.useMemo(()=>i(e,t),[e,t])):f(n,e)},re=(e,t,n)=>{let r=u.useContext(c);u.useEffect(()=>r.subscribe(e,t,n),[r,e,t,n?.immediate])},ie=new Set([`localhost`,`127.0.0.1`,`::1`]);function ae(e){return e.trim().toLowerCase().replace(/^\[(.*)\]$/,`$1`)}function m(e){let t=ae(e);return ie.has(t)||t.endsWith(`.localhost`)}function oe(e){try{return m(new URL(e).hostname)}catch{return!1}}function se(e){let t=e.split(`.`).map(e=>Number(e));if(t.length!==4||t.some(e=>!Number.isInteger(e)||e<0||e>255))return!1;let[n,r]=t;return n===10||n===172&&r>=16&&r<=31||n===192&&r===168}var ce=`/api/dev/local-web/bootstrap`,le=3e3,h=null,g=null,_=null;function v(){return _!==null&&Date.now()-_<le}function ue(e){try{return te(ee)(e)}catch{return null}}function de(){return!1}function y(){return typeof window>`u`?null:window.desktopBridge?.getLocalEnvironmentBootstrap()??h}async function fe(){if(!de()||window.desktopBridge)return h=null,y();let e;try{e=await fetch(new URL(ce,window.location.origin),{credentials:`include`})}catch{return h=null,_=Date.now(),null}if(e.status===204||e.status===404||!e.ok)return h=null,_=Date.now(),null;let t=ue(await e.json().catch(()=>null));return h=t,_=null,t}async function pe(){let e=typeof window>`u`?null:window.desktopBridge?.getLocalEnvironmentBootstrap();return e?(h=null,e):h||(v()?null:g||(g=fe().finally(()=>{g=null}),g))}function b(){return y()}var me=`forge_backend_mode`,he=`forge_apex_url`;function x(){return b()}function S(e){return new URL(e,window.location.origin).toString()}function ge(e,t){let n=new URL(e);return`${n.pathname.endsWith(`/`)?n.pathname.slice(0,-1):n.pathname}${t.startsWith(`/`)?t:`/${t}`}`}function C(e){let t;try{t=new URL(window.location.href)}catch{return e}let n=new URL(e);return(t.protocol===`http:`||t.protocol===`https:`)&&t.port!==``&&n.port!==``&&t.origin!==n.origin&&m(t.hostname)&&m(n.hostname),e}function _e(){return null}function ve(){let e=S(window.location.origin),t=new URL(e);if(t.protocol===`http:`)t.protocol=`ws:`;else if(t.protocol===`https:`)t.protocol=`wss:`;else throw Error(`Unsupported HTTP base URL protocol: ${t.protocol}`);return t.pathname=`/ws`,{source:`window-origin`,target:{httpBaseUrl:e,wsBaseUrl:t.toString()}}}function ye(){try{if(localStorage.getItem(me)!==`apex`)return null;let e=localStorage.getItem(he)?.trim()??void 0??``;if(!e)return null;let t=S(e),n=new URL(t);return n.protocol=t.startsWith(`https:`)?`wss:`:`ws:`,{source:`configured`,target:{httpBaseUrl:t,wsBaseUrl:n.toString()}}}catch{return null}}function be(){let e=x();return!e||e.primaryMode!==`cloud`||!e.bearerToken?null:{source:`paired-bearer`,target:{httpBaseUrl:S(e.httpBaseUrl),wsBaseUrl:S(e.wsBaseUrl)},bearerToken:e.bearerToken}}function xe(){let e=x();if(!e||e.primaryMode===`cloud`||!e.httpBaseUrl&&!e.wsBaseUrl)return null;if(!e.httpBaseUrl||!e.wsBaseUrl)throw Error(`Desktop bootstrap must provide both httpBaseUrl and wsBaseUrl for the local environment.`);return{source:`desktop-managed`,target:{httpBaseUrl:S(e.httpBaseUrl),wsBaseUrl:S(e.wsBaseUrl)},...e.bearerToken?{bearerToken:e.bearerToken}:{}}}function w(e,t){let n=T();if(!n)throw Error(`Unable to resolve the primary environment HTTP base URL.`);let r=new URL(C(n.target.httpBaseUrl));return r.pathname=ge(r.toString(),e),t&&(r.search=new URLSearchParams(t).toString()),r.toString()}function T(){return be()??ye()??xe()??_e()??ve()}function E(e={}){let t=T(),n=t?.bearerToken;return!t||!n||!D(t)?e:{...e,credentials:`omit`,headers:{...e.headers,Authorization:`Bearer ${n}`}}}function D(e){if(e.source!==`desktop-managed`||typeof window>`u`)return!0;try{return new URL(C(e.target.httpBaseUrl)).origin!==window.location.origin}catch{return!0}}async function O(e,t){return await e.text()||t}async function k(){let e=w(`/api/auth/logout`),t=await fetch(e,E({credentials:`include`,method:`POST`}));if(!t.ok)throw Error(await O(t,`Failed to logout authenticated session (${t.status}).`))}var A=1e3,j=2,M=64e3,Se=Object.freeze({attemptCount:0,closeCode:null,closeReason:null,connectedAt:null,disconnectedAt:null,hasConnected:!1,lastError:null,lastErrorAt:null,nextRetryAt:null,online:typeof navigator>`u`||navigator.onLine!==!1,phase:`idle`,reconnectAttemptCount:0,reconnectMaxAttempts:11,reconnectPhase:`idle`,socketUrl:null}),N=l(Se).pipe(s,a(`ws-connection-status`)),P=Object.freeze({status:`ok`}),F=l(P).pipe(s,a(`cloud-auth-failure`));function Ce(e){o.get(F).status!==`expired`&&o.set(F,{status:`expired`,detectedAt:new Date().toISOString(),source:e})}function I(){o.set(F,P)}function we(){return o.get(F)}function L(){return new Date().toISOString()}function R(e){let t=e(z());return o.set(N,t),t}function z(){return o.get(N)}function Te(e){return e.phase===`connected`||e.hasConnected&&e.disconnectedAt===null&&e.phase===`connecting`?`connected`:!e.online&&(e.disconnectedAt!==null||e.phase===`disconnected`)?`offline`:e.hasConnected?`reconnecting`:e.phase===`disconnected`?`error`:`connecting`}function Ee(e){return R(t=>({...t,attemptCount:t.attemptCount+1,nextRetryAt:null,phase:`connecting`,reconnectAttemptCount:t.phase===`connected`?1:t.reconnectAttemptCount+1,reconnectPhase:`attempting`,socketUrl:e}))}function De(){return R(e=>({...e,closeCode:null,closeReason:null,connectedAt:L(),disconnectedAt:null,hasConnected:!0,nextRetryAt:null,phase:`connected`,reconnectAttemptCount:0,reconnectPhase:`idle`}))}function Oe(e){return R(t=>V(t,{lastError:e?.trim()?e:t.lastError,lastErrorAt:L()}))}function ke(e){return R(t=>t.hasConnected&&Ae(e)?t:V(t,{closeCode:e?.code??t.closeCode,closeReason:e?.reason?.trim()?e.reason:t.closeReason}))}function Ae(e){return(e?.reason?.trim()??``).length===0&&(e?.code===1e3||e?.code===1001)}function je(e){return R(t=>({...t,online:e}))}function Me(){return R(e=>({...e,nextRetryAt:null,reconnectAttemptCount:0,reconnectPhase:`idle`}))}function Ne(){return p(N)}function B(e){return!Number.isInteger(e)||e<0||e>=10?null:Math.min(Math.round(A*j**e),M)}function V(e,t){let n=e.disconnectedAt??L(),r=e.nextRetryAt!==null||e.reconnectPhase===`exhausted`?null:B(Math.max(0,e.reconnectAttemptCount-1));return{...e,...t,disconnectedAt:n,nextRetryAt:r===null?e.nextRetryAt:new Date(Date.now()+r).toISOString(),phase:`disconnected`,reconnectPhase:e.reconnectPhase===`waiting`||e.reconnectPhase===`exhausted`?e.reconnectPhase:r===null?`exhausted`:`waiting`}}var H=class extends Error{constructor(e=`Session has expired. Please re-login.`){super(e),this.name=`ForgeAuthExpiredError`}};function Pe(e){return e instanceof H||e instanceof Error&&e.name===`ForgeAuthExpiredError`}var U=`forge_auth_expired_reason`,Fe=`session-expired`,W=`reason`,G=`cmmd-auth-expired`,K={"session-expired":`Session has expired. Please re-login.`,"desktop-session-required":`Forge Desktop needs a CMMD sign-in before this device can host or control runtimes.`,"desktop-principal-mismatch":`Forge Desktop and the local Forge session are signed in to different CMMD accounts. Sign in again to reconcile them.`,"desktop-state-unavailable":`Forge Desktop could not verify its native CMMD session. Restart Forge or sign in again.`};function Ie(e){if(!(e===null||!(e in K)))return K[e]}function q(e){if(!(typeof window>`u`))try{window.sessionStorage.setItem(U,e)}catch{}}function J(){if(typeof window>`u`)return null;try{return new URL(window.location.href).searchParams.getAll(W).includes(G)?Fe:null}catch{return null}}function Y(){if(!(typeof window>`u`))try{let e=new URL(window.location.href),t=e.searchParams.getAll(W);if(!t.includes(G))return;e.searchParams.delete(W);for(let n of t)n!==G&&e.searchParams.append(W,n);window.history.replaceState({},typeof document>`u`?``:document.title,e.toString())}catch{}}function X(){let e=J();return e!==null&&Y(),e}function Le(){if(!(typeof window>`u`)){try{window.sessionStorage.removeItem(U)}catch{}Y()}}function Re(){if(typeof window>`u`)return null;try{let e=window.sessionStorage.getItem(U);return Y(),e}catch{return Y(),null}}function ze(){if(typeof window>`u`)return null;try{let e=window.sessionStorage.getItem(U);return e===null?X():(window.sessionStorage.removeItem(U),Y(),e)}catch{return X()}}async function Z(){await k().catch(()=>void 0),I(),q(`session-expired`);let e=new URL(w(`/login`));window.location.assign(e.toString())}var Be=e({handleCmmdAuthExpired:()=>$}),Q=null;async function $(e){if((e===void 0||e===401)&&!(typeof window>`u`))return Q||(Q=Z().finally(()=>{Q=null}),Q)}export{b as A,je as C,E as D,k as E,re as F,p as I,m as M,oe as N,T as O,se as P,Me as S,Ne as T,B as _,Le as a,Oe as b,Z as c,ze as d,I as f,Te as g,z as h,H as i,pe as j,w as k,Ie as l,we as m,$ as n,Pe as o,F as p,U as r,Re as s,Be as t,q as u,Ee as v,Ce as w,De as x,ke as y};
2
- //# sourceMappingURL=cmmdAuthRedirect-C1FjO86g.js.map
1
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`forge-web@0.9.10`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`176ca5d7-5fd7-4459-8664-3bdf6e6c5813`,e._sentryDebugIdIdentifier=`sentry-dbid-176ca5d7-5fd7-4459-8664-3bdf6e6c5813`)}catch{}})();import{n as e,r as t}from"./rolldown-runtime-BaTzPAyU.js";import{Va as n}from"./Stream-D8tJNlvy.js";import{a as r,c as i,l as a,n as o,o as s,r as c,s as l}from"./atomRegistry-Bz2MHqst.js";import{dt as ee,wn as te}from"./src-BL6J64vk.js";var u=t(n(),1),d=new WeakMap;function ne(e,t){let n=d.get(e);n===void 0&&(n=new WeakMap,d.set(e,n));let i=n.get(t);if(i!==void 0)return i;let a={subscribe(n){return e.subscribe(t,n)},snapshot(){return e.get(t)},getServerSnapshot(){return r(t,e)}};return n.set(t,a),a}function f(e,t){let n=ne(e,t);return u.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}var p=(e,t)=>{let n=u.useContext(c);return t?f(n,u.useMemo(()=>i(e,t),[e,t])):f(n,e)},re=(e,t,n)=>{let r=u.useContext(c);u.useEffect(()=>r.subscribe(e,t,n),[r,e,t,n?.immediate])},ie=new Set([`localhost`,`127.0.0.1`,`::1`]);function ae(e){return e.trim().toLowerCase().replace(/^\[(.*)\]$/,`$1`)}function m(e){let t=ae(e);return ie.has(t)||t.endsWith(`.localhost`)}function oe(e){try{return m(new URL(e).hostname)}catch{return!1}}function se(e){let t=e.split(`.`).map(e=>Number(e));if(t.length!==4||t.some(e=>!Number.isInteger(e)||e<0||e>255))return!1;let[n,r]=t;return n===10||n===172&&r>=16&&r<=31||n===192&&r===168}var ce=`/api/dev/local-web/bootstrap`,le=3e3,h=null,g=null,_=null;function v(){return _!==null&&Date.now()-_<le}function ue(e){try{return te(ee)(e)}catch{return null}}function de(){return!1}function y(){return typeof window>`u`?null:window.desktopBridge?.getLocalEnvironmentBootstrap()??h}async function fe(){if(!de()||window.desktopBridge)return h=null,y();let e;try{e=await fetch(new URL(ce,window.location.origin),{credentials:`include`})}catch{return h=null,_=Date.now(),null}if(e.status===204||e.status===404||!e.ok)return h=null,_=Date.now(),null;let t=ue(await e.json().catch(()=>null));return h=t,_=null,t}async function pe(){let e=typeof window>`u`?null:window.desktopBridge?.getLocalEnvironmentBootstrap();return e?(h=null,e):h||(v()?null:g||(g=fe().finally(()=>{g=null}),g))}function b(){return y()}var me=`forge_backend_mode`,he=`forge_apex_url`;function x(){return b()}function S(e){return new URL(e,window.location.origin).toString()}function ge(e,t){let n=new URL(e);return`${n.pathname.endsWith(`/`)?n.pathname.slice(0,-1):n.pathname}${t.startsWith(`/`)?t:`/${t}`}`}function C(e){let t;try{t=new URL(window.location.href)}catch{return e}let n=new URL(e);return(t.protocol===`http:`||t.protocol===`https:`)&&t.port!==``&&n.port!==``&&t.origin!==n.origin&&m(t.hostname)&&m(n.hostname),e}function _e(){return null}function ve(){let e=S(window.location.origin),t=new URL(e);if(t.protocol===`http:`)t.protocol=`ws:`;else if(t.protocol===`https:`)t.protocol=`wss:`;else throw Error(`Unsupported HTTP base URL protocol: ${t.protocol}`);return t.pathname=`/ws`,{source:`window-origin`,target:{httpBaseUrl:e,wsBaseUrl:t.toString()}}}function ye(){try{if(localStorage.getItem(me)!==`apex`)return null;let e=localStorage.getItem(he)?.trim()??void 0??``;if(!e)return null;let t=S(e),n=new URL(t);return n.protocol=t.startsWith(`https:`)?`wss:`:`ws:`,{source:`configured`,target:{httpBaseUrl:t,wsBaseUrl:n.toString()}}}catch{return null}}function be(){let e=x();return!e||e.primaryMode!==`cloud`||!e.bearerToken?null:{source:`paired-bearer`,target:{httpBaseUrl:S(e.httpBaseUrl),wsBaseUrl:S(e.wsBaseUrl)},bearerToken:e.bearerToken}}function xe(){let e=x();if(!e||e.primaryMode===`cloud`||!e.httpBaseUrl&&!e.wsBaseUrl)return null;if(!e.httpBaseUrl||!e.wsBaseUrl)throw Error(`Desktop bootstrap must provide both httpBaseUrl and wsBaseUrl for the local environment.`);return{source:`desktop-managed`,target:{httpBaseUrl:S(e.httpBaseUrl),wsBaseUrl:S(e.wsBaseUrl)},...e.bearerToken?{bearerToken:e.bearerToken}:{}}}function w(e,t){let n=T();if(!n)throw Error(`Unable to resolve the primary environment HTTP base URL.`);let r=new URL(C(n.target.httpBaseUrl));return r.pathname=ge(r.toString(),e),t&&(r.search=new URLSearchParams(t).toString()),r.toString()}function T(){return be()??ye()??xe()??_e()??ve()}function E(e={}){let t=T(),n=t?.bearerToken;return!t||!n||!D(t)?e:{...e,credentials:`omit`,headers:{...e.headers,Authorization:`Bearer ${n}`}}}function D(e){if(e.source!==`desktop-managed`||typeof window>`u`)return!0;try{return new URL(C(e.target.httpBaseUrl)).origin!==window.location.origin}catch{return!0}}async function O(e,t){return await e.text()||t}async function k(){let e=w(`/api/auth/logout`),t=await fetch(e,E({credentials:`include`,method:`POST`}));if(!t.ok)throw Error(await O(t,`Failed to logout authenticated session (${t.status}).`))}var A=1e3,j=2,M=64e3,Se=Object.freeze({attemptCount:0,closeCode:null,closeReason:null,connectedAt:null,disconnectedAt:null,hasConnected:!1,lastError:null,lastErrorAt:null,nextRetryAt:null,online:typeof navigator>`u`||navigator.onLine!==!1,phase:`idle`,reconnectAttemptCount:0,reconnectMaxAttempts:11,reconnectPhase:`idle`,socketUrl:null}),N=l(Se).pipe(s,a(`ws-connection-status`)),P=Object.freeze({status:`ok`}),F=l(P).pipe(s,a(`cloud-auth-failure`));function Ce(e){o.get(F).status!==`expired`&&o.set(F,{status:`expired`,detectedAt:new Date().toISOString(),source:e})}function I(){o.set(F,P)}function we(){return o.get(F)}function L(){return new Date().toISOString()}function R(e){let t=e(z());return o.set(N,t),t}function z(){return o.get(N)}function Te(e){return e.phase===`connected`||e.hasConnected&&e.disconnectedAt===null&&e.phase===`connecting`?`connected`:!e.online&&(e.disconnectedAt!==null||e.phase===`disconnected`)?`offline`:e.hasConnected?`reconnecting`:e.phase===`disconnected`?`error`:`connecting`}function Ee(e){return R(t=>({...t,attemptCount:t.attemptCount+1,nextRetryAt:null,phase:`connecting`,reconnectAttemptCount:t.phase===`connected`?1:t.reconnectAttemptCount+1,reconnectPhase:`attempting`,socketUrl:e}))}function De(){return R(e=>({...e,closeCode:null,closeReason:null,connectedAt:L(),disconnectedAt:null,hasConnected:!0,nextRetryAt:null,phase:`connected`,reconnectAttemptCount:0,reconnectPhase:`idle`}))}function Oe(e){return R(t=>V(t,{lastError:e?.trim()?e:t.lastError,lastErrorAt:L()}))}function ke(e){return R(t=>t.hasConnected&&Ae(e)?t:V(t,{closeCode:e?.code??t.closeCode,closeReason:e?.reason?.trim()?e.reason:t.closeReason}))}function Ae(e){return(e?.reason?.trim()??``).length===0&&(e?.code===1e3||e?.code===1001)}function je(e){return R(t=>({...t,online:e}))}function Me(){return R(e=>({...e,nextRetryAt:null,reconnectAttemptCount:0,reconnectPhase:`idle`}))}function Ne(){return p(N)}function B(e){return!Number.isInteger(e)||e<0||e>=10?null:Math.min(Math.round(A*j**e),M)}function V(e,t){let n=e.disconnectedAt??L(),r=e.nextRetryAt!==null||e.reconnectPhase===`exhausted`?null:B(Math.max(0,e.reconnectAttemptCount-1));return{...e,...t,disconnectedAt:n,nextRetryAt:r===null?e.nextRetryAt:new Date(Date.now()+r).toISOString(),phase:`disconnected`,reconnectPhase:e.reconnectPhase===`waiting`||e.reconnectPhase===`exhausted`?e.reconnectPhase:r===null?`exhausted`:`waiting`}}var H=class extends Error{constructor(e=`Session has expired. Please re-login.`){super(e),this.name=`ForgeAuthExpiredError`}};function Pe(e){return e instanceof H||e instanceof Error&&e.name===`ForgeAuthExpiredError`}var U=`forge_auth_expired_reason`,Fe=`session-expired`,W=`reason`,G=`cmmd-auth-expired`,K={"session-expired":`Session has expired. Please re-login.`,"desktop-session-required":`Forge Desktop needs a CMMD sign-in before this device can host or control runtimes.`,"desktop-principal-mismatch":`Forge Desktop and the local Forge session are signed in to different CMMD accounts. Sign in again to reconcile them.`,"desktop-state-unavailable":`Forge Desktop could not verify its native CMMD session. Restart Forge or sign in again.`};function Ie(e){if(!(e===null||!(e in K)))return K[e]}function q(e){if(!(typeof window>`u`))try{window.sessionStorage.setItem(U,e)}catch{}}function J(){if(typeof window>`u`)return null;try{return new URL(window.location.href).searchParams.getAll(W).includes(G)?Fe:null}catch{return null}}function Y(){if(!(typeof window>`u`))try{let e=new URL(window.location.href),t=e.searchParams.getAll(W);if(!t.includes(G))return;e.searchParams.delete(W);for(let n of t)n!==G&&e.searchParams.append(W,n);window.history.replaceState({},typeof document>`u`?``:document.title,e.toString())}catch{}}function X(){let e=J();return e!==null&&Y(),e}function Le(){if(!(typeof window>`u`)){try{window.sessionStorage.removeItem(U)}catch{}Y()}}function Re(){if(typeof window>`u`)return null;try{let e=window.sessionStorage.getItem(U);return Y(),e}catch{return Y(),null}}function ze(){if(typeof window>`u`)return null;try{let e=window.sessionStorage.getItem(U);return e===null?X():(window.sessionStorage.removeItem(U),Y(),e)}catch{return X()}}async function Z(){await k().catch(()=>void 0),I(),q(`session-expired`);let e=new URL(w(`/login`));window.location.assign(e.toString())}var Be=e({handleCmmdAuthExpired:()=>$}),Q=null;async function $(e){if((e===void 0||e===401)&&!(typeof window>`u`))return Q||(Q=Z().finally(()=>{Q=null}),Q)}export{b as A,je as C,E as D,k as E,re as F,p as I,m as M,oe as N,T as O,se as P,Me as S,Ne as T,B as _,Le as a,Oe as b,Z as c,ze as d,I as f,Te as g,z as h,H as i,pe as j,w as k,Ie as l,we as m,$ as n,Pe as o,F as p,U as r,Re as s,Be as t,q as u,Ee as v,Ce as w,De as x,ke as y};
2
+ //# sourceMappingURL=cmmdAuthRedirect-lmPzseq5.js.map