@popmelt.com/core 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -29
- package/THIRD_PARTY_NOTICES.md +26 -0
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/claude-plugin/skills/popmelt-core/SKILL.md +1 -0
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/codex-plugin/skills/popmelt-core/SKILL.md +1 -0
- package/dist/ExploreAttachment-IO3CNUWH.mjs +1 -0
- package/dist/PagePreviewLayer-KQ2FLIGX.mjs +1 -0
- package/dist/ParticipantRuntime-Y2BQVJSL.mjs +1 -0
- package/dist/PhoneHostGate-2G4BA5FP.mjs +1 -0
- package/dist/PopmeltTasteConnectedPane-H5QWBFD7.mjs +1 -0
- package/dist/PreviewRuntime-V2PZF462.mjs +1 -0
- package/dist/QueuedReplies-4APDDNQX.mjs +1 -0
- package/dist/SamplePlacementOverlay-ELSP5AHM.mjs +1 -0
- package/dist/ShareProjectPane-OR2LS2A3.mjs +1 -0
- package/dist/SuppliedContext-SAQKEDWW.mjs +1 -0
- package/dist/ThreadErrorCard-OSHIWSHR.mjs +1 -0
- package/dist/ThreadPanel-YPL2HDUC.mjs +1 -0
- package/dist/adapter-react-three-fiber.d.mts +6 -2
- package/dist/adapter-react-three-fiber.mjs +1 -1
- package/dist/adapter-three.d.mts +34 -0
- package/dist/adapter-three.mjs +45 -1
- package/dist/bridge-entry.mjs +1 -1
- package/dist/bridgeSSEStream-6OMAFDFW.mjs +1 -0
- package/dist/bridgeWebSocketStream-WIOGOPJW.mjs +1 -0
- package/dist/browser-runtime-O3EKN3FI.mjs +1 -0
- package/dist/browser.d.mts +4 -4
- package/dist/browser.mjs +1 -1
- package/dist/canvas-chat-note-O3USBECW.mjs +1 -0
- package/dist/checkFixture-SOSI7AT4.mjs +1 -0
- package/dist/chunk-3VOEPWRL.mjs +1 -0
- package/dist/chunk-4OEHQ6M7.mjs +24 -0
- package/dist/chunk-4YQWU5YB.mjs +1 -0
- package/dist/chunk-5IZHN3A7.mjs +1 -0
- package/dist/chunk-6EO73WJN.mjs +1 -0
- package/dist/{chunk-66VOM5NA.mjs → chunk-6O5QLRSA.mjs} +1 -1
- package/dist/chunk-76WRZ2NH.mjs +1 -0
- package/dist/chunk-A4GARXVQ.mjs +1 -0
- package/dist/chunk-AAMUU2QA.mjs +1 -0
- package/dist/chunk-AGCS65LT.mjs +1 -0
- package/dist/chunk-AGYBVMHX.mjs +1 -0
- package/dist/{chunk-RR4SHK7O.mjs → chunk-AOTDTBQO.mjs} +1 -1
- package/dist/chunk-ATLUO4G7.mjs +1 -0
- package/dist/chunk-AYZUOBFI.mjs +1 -0
- package/dist/chunk-B22WBEQC.mjs +1 -0
- package/dist/chunk-B2ISA6V6.mjs +1 -0
- package/dist/chunk-B4DYUYX4.mjs +1 -0
- package/dist/chunk-BVGHHT3Y.mjs +1 -0
- package/dist/{chunk-NDGM4DAP.mjs → chunk-BYASSHKJ.mjs} +1 -1
- package/dist/chunk-C2ZSNUXQ.mjs +1 -0
- package/dist/chunk-CIA6WVXQ.mjs +1 -0
- package/dist/chunk-CIKFUS7J.mjs +1 -0
- package/dist/chunk-CK3CDA3L.mjs +1 -0
- package/dist/{chunk-M5P6VHZY.mjs → chunk-DO46YJCX.mjs} +1 -1
- package/dist/chunk-DRPRASD6.mjs +1 -0
- package/dist/chunk-EBJ23A7F.mjs +1 -0
- package/dist/chunk-ECMLCGAM.mjs +1 -0
- package/dist/chunk-EILBHZDX.mjs +1 -0
- package/dist/{chunk-DOCRI237.mjs → chunk-ELKVFX2O.mjs} +1 -1
- package/dist/chunk-EUFR7R5Q.mjs +1 -0
- package/dist/chunk-EZVFCJEG.mjs +1 -0
- package/dist/chunk-FHCKFQBY.mjs +1 -0
- package/dist/chunk-FJWWBKCQ.mjs +1 -0
- package/dist/chunk-FON4QY7P.mjs +1 -0
- package/dist/chunk-GLF7Z5IR.mjs +1 -0
- package/dist/chunk-HAZXZ5TU.mjs +1 -0
- package/dist/chunk-HKHZBKAN.mjs +1 -0
- package/dist/chunk-I6FJ533W.mjs +1 -0
- package/dist/chunk-I7AI52RX.mjs +1 -0
- package/dist/chunk-IAXSC2ZN.mjs +1 -0
- package/dist/chunk-IGKU4YIV.mjs +1 -0
- package/dist/chunk-IW7V7WNL.mjs +1 -0
- package/dist/chunk-JCW2WY7X.mjs +1 -0
- package/dist/chunk-JEGBAHYK.mjs +1 -0
- package/dist/chunk-JLK3VRBT.mjs +1 -0
- package/dist/chunk-KCDHP4N3.mjs +1 -0
- package/dist/chunk-KF73S7MG.mjs +1 -0
- package/dist/chunk-L6S66APQ.mjs +1 -0
- package/dist/chunk-LH7HKUCK.mjs +1 -0
- package/dist/chunk-LOUWY55X.mjs +1 -0
- package/dist/chunk-LXFKOYLK.mjs +1 -0
- package/dist/chunk-MDPZUECK.mjs +1 -0
- package/dist/chunk-MHWIFSXJ.mjs +1 -0
- package/dist/chunk-MPEVFQ43.mjs +1 -0
- package/dist/{chunk-57FM7XQV.mjs → chunk-NI77Y3WC.mjs} +1 -1
- package/dist/chunk-NXTWB3A7.mjs +1 -0
- package/dist/chunk-OA63PYHZ.mjs +1 -0
- package/dist/chunk-OFJUTWJU.mjs +1 -0
- package/dist/chunk-OREALBUO.mjs +1 -0
- package/dist/chunk-OVZ4CQGM.mjs +1 -0
- package/dist/{chunk-XG2YIAJS.mjs → chunk-OZBMHEOD.mjs} +1 -1
- package/dist/chunk-PILMDBAX.mjs +1 -0
- package/dist/chunk-PLE6FFKY.mjs +1 -0
- package/dist/chunk-PRPXMDZ7.mjs +1 -0
- package/dist/chunk-PWQB3FIW.mjs +1 -0
- package/dist/chunk-ROKRMYFR.mjs +1 -0
- package/dist/chunk-SNAJBV7T.mjs +30 -0
- package/dist/chunk-SOGN7S54.mjs +1 -0
- package/dist/chunk-SOT33EQ4.mjs +1 -0
- package/dist/chunk-SQA27YGA.mjs +1 -0
- package/dist/chunk-SUAHDXJZ.mjs +1 -0
- package/dist/chunk-TCGXG7UA.mjs +1 -0
- package/dist/chunk-TMSGNHXH.mjs +1 -0
- package/dist/chunk-TQ3SP5TE.mjs +1 -0
- package/dist/chunk-UTP56NCY.mjs +1 -0
- package/dist/chunk-W2QQVB2H.mjs +1 -0
- package/dist/chunk-WC4ZNVFM.mjs +1 -0
- package/dist/chunk-WDSFOF2E.mjs +1 -0
- package/dist/chunk-WP2SHSCG.mjs +1 -0
- package/dist/chunk-X6I6KQDG.mjs +1 -0
- package/dist/chunk-XJJDBMZI.mjs +1 -0
- package/dist/chunk-XY7YW7SH.mjs +1 -0
- package/dist/chunk-YMWXWXPV.mjs +1 -0
- package/dist/chunk-YU3ZY76H.mjs +1 -0
- package/dist/chunk-YVT3J6JB.mjs +1 -0
- package/dist/chunk-YYFF2X3L.mjs +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/codex-note-context-UI55CWRI.mjs +1 -0
- package/dist/codex-project-LIU27RXA.mjs +1 -0
- package/dist/codex-session-registry-YNU6LEVH.mjs +1 -0
- package/dist/codex-store-mount-EPETPOBA.mjs +1 -0
- package/dist/{dev-server-DtX2_HCa.d.mts → dev-server-BRrhkH5t.d.mts} +11 -1
- package/dist/dev-server-WYB2CRC5.mjs +1 -0
- package/dist/focus-inspection-42IEM45O.mjs +1 -0
- package/dist/guest-admission.d.mts +2 -0
- package/dist/guest-admission.mjs +1 -0
- package/dist/guest-live-canvas.d.mts +2 -0
- package/dist/guest-live-canvas.mjs +1 -0
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +1 -1
- package/dist/invitationLink-LUIIOAEZ.mjs +1 -0
- package/dist/inviteQr-HVHH45SN.mjs +1 -0
- package/dist/inviteQr-U77MLSEQ.mjs +1 -0
- package/dist/media.d.mts +3 -3
- package/dist/memory-store.d.mts +5 -1
- package/dist/page-interaction-TV3P6B3X.mjs +1 -0
- package/dist/page-planes-2ZepTpen.d.mts +817 -0
- package/dist/participantBootstrap-BuTrTQbo.d.mts +22 -0
- package/dist/{participantBootstrap-DFJlcKRI.d.mts → participantBootstrap-DuosDN9G.d.mts} +9 -3
- package/dist/peer-client-RSC6EGAF.mjs +1 -0
- package/dist/plain-html-EF7MUNRZ.mjs +1 -0
- package/dist/plugin-astro.d.mts +5 -2
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-next.mjs +1 -1
- package/dist/plugin-nuxt.d.mts +4 -2
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.d.mts +86 -9
- package/dist/plugin-vite.mjs +1 -1
- package/dist/qr-encoder.mjs +3 -0
- package/dist/server.d.mts +43 -20
- package/dist/server.mjs +1 -1
- package/dist/shared-page-GO76UP7I.mjs +1 -0
- package/dist/{subjects-DdavjSTL.d.mts → subjects-BhO1x5tz.d.mts} +80 -1
- package/dist/taste-proposal-session-DBOUA54V.mjs +1 -0
- package/dist/toolbarFonts-GVPRHJGB.mjs +1 -0
- package/dist/{types-C8tjyhiF.d.mts → types-CggBG-H6.d.mts} +1 -136
- package/dist/{video-adapter-DB6Hex1f.d.mts → video-adapter-B8J5awc_.d.mts} +2 -2
- package/dist/workspace-snapshot-6LN7U2NJ.mjs +1 -0
- package/package.json +46 -22
- package/samples/README.md +32 -0
- package/samples/build.d.mts +16 -0
- package/samples/build.mjs +138 -0
- package/dist/ExploreAttachment-TTEKD4AU.mjs +0 -1
- package/dist/PagePreviewLayer-TJZOJBSD.mjs +0 -1
- package/dist/ParticipantRuntime-BQAOTSQZ.mjs +0 -1
- package/dist/PhoneHostGate-LNSDZOG2.mjs +0 -1
- package/dist/PopmeltTasteConnectedPane-NCCF7YUX.mjs +0 -1
- package/dist/PreviewRuntime-H2UOLP6T.mjs +0 -1
- package/dist/QueuedReplies-LQUBEZ6K.mjs +0 -1
- package/dist/SuppliedContext-YKQSMF3J.mjs +0 -1
- package/dist/ThreadErrorCard-4MOA34C4.mjs +0 -1
- package/dist/ThreadPanel-T6IXWFLA.mjs +0 -1
- package/dist/bridgeSSEStream-K3UIMBTC.mjs +0 -1
- package/dist/bridgeWebSocketStream-2SUZUBE3.mjs +0 -1
- package/dist/browser-runtime-HQM2Y6EL.mjs +0 -1
- package/dist/canvas-chat-note-MGAEUYJO.mjs +0 -1
- package/dist/checkFixture-BXILOUP5.mjs +0 -1
- package/dist/chunk-2P2NUZW7.mjs +0 -1
- package/dist/chunk-4LHTPRFY.mjs +0 -1
- package/dist/chunk-5D2ADU7H.mjs +0 -1
- package/dist/chunk-5K7SACPW.mjs +0 -1
- package/dist/chunk-67QNAAUC.mjs +0 -1
- package/dist/chunk-6LBPTCGC.mjs +0 -1
- package/dist/chunk-AYDREFWN.mjs +0 -1
- package/dist/chunk-CRJPE33X.mjs +0 -1
- package/dist/chunk-DC47WNPG.mjs +0 -1
- package/dist/chunk-DJTGR3RO.mjs +0 -1
- package/dist/chunk-DOJBWTT5.mjs +0 -1
- package/dist/chunk-EX63NVDN.mjs +0 -1
- package/dist/chunk-F45IVFS3.mjs +0 -1
- package/dist/chunk-F5XSNRGT.mjs +0 -1
- package/dist/chunk-G7JR5Z3P.mjs +0 -1
- package/dist/chunk-GKOMTSWV.mjs +0 -1
- package/dist/chunk-HAE5LUJX.mjs +0 -1
- package/dist/chunk-HU2XWUJC.mjs +0 -1
- package/dist/chunk-HV7HRQ2S.mjs +0 -1
- package/dist/chunk-J4WDYITA.mjs +0 -1
- package/dist/chunk-KTRMNVPZ.mjs +0 -1
- package/dist/chunk-LVEMYZOA.mjs +0 -1
- package/dist/chunk-N4737FRL.mjs +0 -1
- package/dist/chunk-NSCO633B.mjs +0 -1
- package/dist/chunk-O4HZP3RP.mjs +0 -1
- package/dist/chunk-OAHYSDJ4.mjs +0 -1
- package/dist/chunk-PQT5FYN5.mjs +0 -1
- package/dist/chunk-R34FOW4D.mjs +0 -1
- package/dist/chunk-RUTWU5W2.mjs +0 -1
- package/dist/chunk-S7BCEQKP.mjs +0 -1
- package/dist/chunk-T4CCY2EL.mjs +0 -1
- package/dist/chunk-TH7DML4A.mjs +0 -1
- package/dist/chunk-UEGDSECJ.mjs +0 -1
- package/dist/chunk-V2I7PSJW.mjs +0 -1
- package/dist/chunk-WDAXARLI.mjs +0 -1
- package/dist/chunk-WHJEKDNP.mjs +0 -1
- package/dist/chunk-XM6RE6HT.mjs +0 -1
- package/dist/chunk-XT6PHPPG.mjs +0 -1
- package/dist/chunk-Y3SF5YCR.mjs +0 -1
- package/dist/chunk-ZG6XHKYO.mjs +0 -1
- package/dist/chunk-ZG7MAEEV.mjs +0 -30
- package/dist/codex-note-context-OUG4S6XE.mjs +0 -1
- package/dist/codex-project-B5466BL6.mjs +0 -1
- package/dist/codex-session-registry-ONODFWFD.mjs +0 -1
- package/dist/focus-inspection-SZJ5KP23.mjs +0 -1
- package/dist/peer-client-SCSWLRCX.mjs +0 -1
- package/dist/taste-proposal-session-XU4N7RUV.mjs +0 -1
- package/dist/workspace-snapshot-RTTXNNUX.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";var a="\n 0%, 100% { translate: 0 0; }\n 20% { translate: -4px 0; }\n 45% { translate: 4px 0; }\n 70% { translate: -2px 0; }\n 88% { translate: 1px 0; }\n";export{a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useId as e,useState as t,useLayoutEffect as n}from"react";function i(i,r){let o=e(),[s,a]=t(-1),[c,l]=t(!1),u=r.some(({suffix:e})=>e);n(()=>{let e=i.current;if(!e||!u)return;let t=()=>a(e.matches(":focus")&&e.selectionStart===e.selectionEnd?e.selectionEnd:-1),n=()=>a(-1);return t(),e.addEventListener("selectionchange",t),e.addEventListener("select",t),e.addEventListener("input",t),e.addEventListener("focus",t),e.addEventListener("blur",n),()=>{e.removeEventListener("selectionchange",t),e.removeEventListener("select",t),e.removeEventListener("input",t),e.removeEventListener("focus",t),e.removeEventListener("blur",n)}},[u,i]);let d=c?void 0:r.find(({start:e,token:t,suffix:n})=>n&&e+t.length===s);return{active:d,complete:function(e,t){let n=e.currentTarget;if(!d||"Tab"!==e.key||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey||e.nativeEvent.isComposing||n.selectionStart!==s||n.selectionEnd!==s)return!1;e.preventDefault(),e.stopPropagation();let i=/\s/.test(n.value.charAt(s)),r=d.suffix+(i?"":" ");return n.ownerDocument.execCommand?.("insertText",!1,r)||(n.setRangeText(r,s,s,"end"),t()),i&&n.setSelectionRange(s+r.length+1,s+r.length+1),!0},hintId:o,inputProps:{"aria-autocomplete":d?"inline":void 0,"aria-describedby":d?o:void 0,onCompositionStart:()=>l(!0),onCompositionEnd:()=>l(!1)}}}export{i as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{c as e}from"./chunk-ZSL57PQ7.mjs";import{jsx as t,jsxs as i}from"react/jsx-runtime";var l="ui-monospace, SFMono-Regular, Menlo, monospace",r=0;function n({size:e=11}){let l=++r,n=`pm-vs-m${l}`,o=`pm-vs-f0-${l}`,s=`pm-vs-f1-${l}`,a=`pm-vs-g${l}`;return i("svg",{width:e,height:e,viewBox:"0 0 100 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{display:"inline",verticalAlign:"middle",marginLeft:3,flexShrink:0},children:[t("mask",{id:n,style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"100",height:"100",children:t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M70.9119 99.3171C72.4869 99.9307 74.2828 99.8914 75.8725 99.1264L96.4608 89.2197C98.6242 88.1787 100 85.9892 100 83.5872V16.4133C100 14.0113 98.6243 11.8218 96.4609 10.7808L75.8725 0.873756C73.7862 -0.130129 71.3446 0.11576 69.5135 1.44695C69.252 1.63711 69.0028 1.84943 68.769 2.08341L29.3551 38.0415L12.1872 25.0096C10.589 23.7965 8.35363 23.8959 6.86933 25.2461L1.36303 30.2549C-0.452552 31.9064 -0.454633 34.7627 1.35853 36.417L16.2471 50.0001L1.35853 63.5832C-0.454633 65.2374 -0.452552 68.0938 1.36303 69.7453L6.86933 74.7541C8.35363 76.1043 10.589 76.2037 12.1872 74.9905L29.3551 61.9587L68.769 97.9167C69.3925 98.5406 70.1246 99.0104 70.9119 99.3171ZM75.0152 27.2989L45.1091 50.0001L75.0152 72.7012V27.2989Z",fill:"white"})}),i("g",{mask:`url(#${n})`,children:[t("path",{d:"M96.4614 10.7962L75.8569 0.875542C73.4719 -0.272773 70.6217 0.211611 68.75 2.08333L1.29858 63.5832C-0.515693 65.2373 -0.513607 68.0937 1.30308 69.7452L6.81272 74.754C8.29793 76.1042 10.5347 76.2036 12.1338 74.9905L93.3609 13.3699C96.086 11.3026 100 13.2462 100 16.6667V16.4275C100 14.0265 98.6246 11.8378 96.4614 10.7962Z",fill:"#0065A9"}),t("g",{filter:`url(#${o})`,children:t("path",{d:"M96.4614 89.2038L75.8569 99.1245C73.4719 100.273 70.6217 99.7884 68.75 97.9167L1.29858 36.4169C-0.515693 34.7627 -0.513607 31.9063 1.30308 30.2548L6.81272 25.246C8.29793 23.8958 10.5347 23.7964 12.1338 25.0095L93.3609 86.6301C96.086 88.6974 100 86.7538 100 83.3334V83.5726C100 85.9735 98.6246 88.1622 96.4614 89.2038Z",fill:"#007ACC"})}),t("g",{filter:`url(#${s})`,children:t("path",{d:"M75.8578 99.1263C73.4721 100.274 70.6219 99.7885 68.75 97.9166C71.0564 100.223 75 98.5895 75 95.3278V4.67213C75 1.41039 71.0564 -0.223106 68.75 2.08329C70.6219 0.211402 73.4721 -0.273666 75.8578 0.873633L96.4587 10.7807C98.6234 11.8217 100 14.0112 100 16.4132V83.5871C100 85.9891 98.6234 88.1786 96.4586 89.2196L75.8578 99.1263Z",fill:"#1F9CF0"})}),t("g",{style:{mixBlendMode:"overlay"},opacity:"0.25",children:t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M70.8511 99.3171C72.4261 99.9306 74.2221 99.8913 75.8117 99.1264L96.4 89.2197C98.5634 88.1787 99.9392 85.9892 99.9392 83.5871V16.4133C99.9392 14.0112 98.5635 11.8217 96.4001 10.7807L75.8117 0.873695C73.7255 -0.13019 71.2838 0.115699 69.4527 1.44688C69.1912 1.63705 68.942 1.84937 68.7082 2.08335L29.2943 38.0414L12.1264 25.0096C10.5283 23.7964 8.29285 23.8959 6.80855 25.246L1.30225 30.2548C-0.513334 31.9064 -0.515415 34.7627 1.29775 36.4169L16.1863 50L1.29775 63.5832C-0.515415 65.2374 -0.513334 68.0937 1.30225 69.7452L6.80855 74.754C8.29285 76.1042 10.5283 76.2036 12.1264 74.9905L29.2943 61.9586L68.7082 97.9167C69.3317 98.5405 70.0638 99.0104 70.8511 99.3171ZM74.9544 27.2989L45.0483 50L74.9544 72.7012V27.2989Z",fill:`url(#${a})`})})]}),i("defs",{children:[i("filter",{id:o,x:"-8.39411",y:"15.8291",width:"116.727",height:"92.2456",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[t("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),t("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"}),t("feOffset",{}),t("feGaussianBlur",{stdDeviation:"4.16667"}),t("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"}),t("feBlend",{mode:"overlay",in2:"BackgroundImageFix",result:"effect1_dropShadow"}),t("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow",result:"shape"})]}),i("filter",{id:s,x:"60.4167",y:"-8.07558",width:"47.9167",height:"116.151",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[t("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),t("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"}),t("feOffset",{}),t("feGaussianBlur",{stdDeviation:"4.16667"}),t("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"}),t("feBlend",{mode:"overlay",in2:"BackgroundImageFix",result:"effect1_dropShadow"}),t("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow",result:"shape"})]}),i("linearGradient",{id:a,x1:"49.9392",y1:"0.257812",x2:"49.9392",y2:"99.7423",gradientUnits:"userSpaceOnUse",children:[t("stop",{stopColor:"white"}),t("stop",{offset:"1",stopColor:"white",stopOpacity:"0"})]})]})]})}var o=/^#[0-9a-fA-F]{3,8}$/,s=/^(?:rgba?|hsla?|oklch)\([^)]+\)$/,a=new Set(["black","white","red","blue","green","yellow","orange","purple","pink","gray","grey","cyan","magenta","brown","navy","teal","maroon","olive","silver","aqua","fuchsia","lime"]);function d(e){let t=e.trim();return o.test(t)||s.test(t)||a.has(t.toLowerCase())}function h(e,i){return t("span",{style:{display:"inline-block",width:10,height:10,backgroundColor:e,border:"1px solid rgba(0,0,0,0.15)",borderRadius:2,verticalAlign:"middle",marginRight:3}},i)}function p(e){let i=e.split(/(?<![^\s([{])(@(?:codex|claude))(?=$|[\s.,!?:;)\]}])/gi);return 1===i.length?e:i.map((e,i)=>i%2?t("strong",{"data-popmelt-tool-mention":!0,children:e},i):e)}function c(e){let r,o=[],s=/(`[^`]+`)|(\*\*\*(.+?)\*\*\*)|(\*\*(.+?)\*\*)|(\*(.+?)\*)|(_([^_]+?)_)|(\[([^\]]+)\]\(([^)]+)\))|(#[0-9a-fA-F]{3,8})(?![0-9a-fA-F])|((?:rgba?|hsla?|oklch)\([^)]+\))/g,a=0;for(;null!==(r=s.exec(e));){if(r.index>a&&o.push(p(e.slice(a,r.index))),r[1]){let e=r[1].slice(1,-1);d(e)&&o.push(h(e,`sw-${r.index}`)),o.push(t("code",{style:{fontFamily:l,fontSize:"0.9em",backgroundColor:"rgba(0,0,0,0.06)",padding:"1px 4px",borderRadius:2},children:e},r.index))}else if(void 0!==r[3])o.push(t("strong",{children:t("em",{children:r[3]})},r.index));else if(void 0!==r[5])o.push(t("strong",{children:r[5]},r.index));else if(void 0!==r[7])o.push(t("em",{children:r[7]},r.index));else if(void 0!==r[9])o.push(t("em",{children:r[9]},r.index));else if(void 0!==r[11]&&void 0!==r[12]){let e=r[12],s=!/^https?:\/\/|^mailto:/i.test(e),a=s?`vscode://file/${e}`:e;s?o.push(i("a",{href:a,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline",whiteSpace:"nowrap",backgroundColor:"rgba(0,0,0,0.06)",padding:"1px 4px",borderRadius:2,fontFamily:l,fontSize:"0.9em"},children:[r[11],t(n,{})]},r.index)):o.push(t("a",{href:a,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"},children:r[11]},r.index))}else void 0!==r[13]?(o.push(h(r[13],`sw-${r.index}`)),o.push(r[13])):void 0!==r[14]&&(o.push(h(r[14],`sw-${r.index}`)),o.push(r[14]));a=r.index+r[0].length}return a<e.length&&o.push(p(e.slice(a))),o}function f(e){let i=e.split("\n"),r=[],n=0;for(;n<i.length;){let e=i[n];if(e.trimStart().startsWith("```")){let e=[];for(n++;n<i.length&&!i[n].trimStart().startsWith("```");)e.push(i[n]),n++;n++,r.push(t("pre",{style:{fontFamily:l,fontSize:"0.9em",lineHeight:1.4,backgroundColor:"rgba(0,0,0,0.04)",padding:"6px 8px",margin:"4px 0",overflowX:"auto",whiteSpace:"pre"},children:e.join("\n")},r.length));continue}if(/^(-{3,}|\*{3,}|_{3,})\s*$/.test(e)){r.push(t("hr",{style:{border:"none",borderTop:"1px solid rgba(0,0,0,0.1)",margin:"6px 0"}},r.length)),n++;continue}let o=e.match(/^(#{1,4})\s+(.+)/);if(o){let e=o[1].length,i={1:16,2:14,3:13,4:12};r.push(t("div",{style:{fontWeight:700,fontSize:i[e]??12,margin:"8px 0 2px"},children:c(o[2])},r.length)),n++;continue}if(e.trimStart().startsWith("|")&&e.trimEnd().endsWith("|")){let e=[];for(;n<i.length&&i[n].trimStart().startsWith("|")&&i[n].trimEnd().endsWith("|");)e.push(i[n]),n++;let l=e=>/^\|[\s\-:|]+\|$/.test(e),o=e.filter(e=>!l(e)),s=e=>e.split("|").slice(1,-1).map(e=>e.trim()),a=e=>/^\*\*.+\*\*$/.test(e)||/^__.+__$/.test(e),d=o.map(s),h=d.length>1&&d.slice(1).every(e=>e[0]&&a(e[0])),p=d.length>0&&d[0].every(e=>a(e));r.push(t("div",{style:{overflowX:"auto",margin:"4px 0",paddingBottom:4},children:t("table",{style:{borderCollapse:"separate",borderSpacing:0,fontSize:"0.95em",width:"max-content",minWidth:"100%"},children:t("tbody",{children:o.map((e,i)=>t("tr",{children:s(e).map((e,l)=>t(0===i?"th":"td",{style:{border:"1px solid rgba(0,0,0,0.1)",padding:"3px 6px",textAlign:"left",fontWeight:0===i?600:400,minWidth:60,whiteSpace:"nowrap",...0===l&&h||0===i&&p?{position:"sticky",...0===l&&h?{left:0}:{},...0===i&&p?{top:0}:{},background:"#fff",zIndex:0===l&&h&&0===i&&p?2:1}:{}},children:c(e)},l))},i))})})},r.length));continue}if(e.match(/^(\s*)([-*])\s+(.+)/)){let e=[];for(;n<i.length;){let t=i[n].match(/^\s*[-*]\s+(.+)/);if(t)e.push(t[1]),n++;else{if(!(e.length>0&&i[n].match(/^\s+\S/))||i[n].match(/^\s*\d+\.\s/)||i[n].match(/^\s*[-*]\s+/))break;e[e.length-1]+=" "+i[n].trim(),n++}}r.push(t("ul",{style:{margin:0,paddingLeft:20,listStyleType:"disc",display:"flex",flexDirection:"column",gap:8,fontSize:"inherit",lineHeight:"inherit"},children:e.map((e,i)=>t("li",{children:c(e)},i))},r.length));continue}let s=e.match(/^(\s*)(\d+)\.\s+(.+)/);if(s){let e=s[1].length,l=parseInt(s[2],10)||1,o=[],a=null;for(;n<i.length;){let t=i[n],l=t.match(/^(\s*)(\d+)\.\s+(.+)/);if(l&&l[1].length===e)a=[l[3]],o.push(a),n++;else if(a&&""===t.trim())n++;else if(o.length>0&&i[n].match(/^\s+\S/)&&!i[n].match(/^\s*\d+\.\s/)&&!i[n].match(/^\s*[-*]\s+/))a.push(i[n].trim()),n++;else if(a&&/^(Eval|Checks|Sources|Rationale|Prompt|Assertions?|Reason|Why|Expected|Notes?):/i.test(t.trim()))a.push(t.trim()),n++;else{if(!(a&&a.length>1&&t.trim())||t.match(/^(#{1,4})\s+/)||t.trimStart().startsWith("|")||t.match(/^\s*[-*]\s+/)||t.match(/^\s*\d+\.\s+/)||/^(\*\*)?[A-Z][A-Za-z /&-]{2,40}(\*\*)?$/.test(t.trim()))break;a.push(t.trim()),n++}}r.push(t("ol",{start:l,style:{margin:0,paddingLeft:20,listStyleType:"decimal",display:"flex",flexDirection:"column",gap:8,fontSize:"inherit",lineHeight:"inherit"},children:o.map((e,i)=>t("li",{children:t("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.map((e,i)=>t("div",{children:c(e)},i))})},i))},r.length));continue}""!==e.trim()?(r.push(t("div",{style:{fontSize:"inherit",lineHeight:"inherit"},children:c(e)},r.length)),n++):n++}return t("div",{style:{display:"flex",flexDirection:"column",fontSize:"inherit",gap:8,lineHeight:"inherit"},children:r})}var m={color:"var(--popmelt-thread-primary)",fontSize:14,letterSpacing:"0.14px",lineHeight:1.3,wordBreak:"break-word"};function u({text:i}){return t("div",{"data-popmelt-response-text":"",style:m,children:t(e,{children:f(i)})})}function g(e){let t=e.createElement("style");return t.textContent=":root, body { overflow: hidden !important; overscroll-behavior: none !important; }",e.head.append(t),()=>t.remove()}export{p as a,f as b,m as c,u as d,g as e};
|
|
1
|
+
"use client";import{c as e}from"./chunk-ZSL57PQ7.mjs";import{jsx as t,jsxs as i}from"react/jsx-runtime";var l="ui-monospace, SFMono-Regular, Menlo, monospace",r=0;function n({size:e=11}){let l=++r,n=`pm-vs-m${l}`,o=`pm-vs-f0-${l}`,s=`pm-vs-f1-${l}`,a=`pm-vs-g${l}`;return i("svg",{width:e,height:e,viewBox:"0 0 100 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{display:"inline",verticalAlign:"middle",marginLeft:3,flexShrink:0},children:[t("mask",{id:n,style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"100",height:"100",children:t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M70.9119 99.3171C72.4869 99.9307 74.2828 99.8914 75.8725 99.1264L96.4608 89.2197C98.6242 88.1787 100 85.9892 100 83.5872V16.4133C100 14.0113 98.6243 11.8218 96.4609 10.7808L75.8725 0.873756C73.7862 -0.130129 71.3446 0.11576 69.5135 1.44695C69.252 1.63711 69.0028 1.84943 68.769 2.08341L29.3551 38.0415L12.1872 25.0096C10.589 23.7965 8.35363 23.8959 6.86933 25.2461L1.36303 30.2549C-0.452552 31.9064 -0.454633 34.7627 1.35853 36.417L16.2471 50.0001L1.35853 63.5832C-0.454633 65.2374 -0.452552 68.0938 1.36303 69.7453L6.86933 74.7541C8.35363 76.1043 10.589 76.2037 12.1872 74.9905L29.3551 61.9587L68.769 97.9167C69.3925 98.5406 70.1246 99.0104 70.9119 99.3171ZM75.0152 27.2989L45.1091 50.0001L75.0152 72.7012V27.2989Z",fill:"white"})}),i("g",{mask:`url(#${n})`,children:[t("path",{d:"M96.4614 10.7962L75.8569 0.875542C73.4719 -0.272773 70.6217 0.211611 68.75 2.08333L1.29858 63.5832C-0.515693 65.2373 -0.513607 68.0937 1.30308 69.7452L6.81272 74.754C8.29793 76.1042 10.5347 76.2036 12.1338 74.9905L93.3609 13.3699C96.086 11.3026 100 13.2462 100 16.6667V16.4275C100 14.0265 98.6246 11.8378 96.4614 10.7962Z",fill:"#0065A9"}),t("g",{filter:`url(#${o})`,children:t("path",{d:"M96.4614 89.2038L75.8569 99.1245C73.4719 100.273 70.6217 99.7884 68.75 97.9167L1.29858 36.4169C-0.515693 34.7627 -0.513607 31.9063 1.30308 30.2548L6.81272 25.246C8.29793 23.8958 10.5347 23.7964 12.1338 25.0095L93.3609 86.6301C96.086 88.6974 100 86.7538 100 83.3334V83.5726C100 85.9735 98.6246 88.1622 96.4614 89.2038Z",fill:"#007ACC"})}),t("g",{filter:`url(#${s})`,children:t("path",{d:"M75.8578 99.1263C73.4721 100.274 70.6219 99.7885 68.75 97.9166C71.0564 100.223 75 98.5895 75 95.3278V4.67213C75 1.41039 71.0564 -0.223106 68.75 2.08329C70.6219 0.211402 73.4721 -0.273666 75.8578 0.873633L96.4587 10.7807C98.6234 11.8217 100 14.0112 100 16.4132V83.5871C100 85.9891 98.6234 88.1786 96.4586 89.2196L75.8578 99.1263Z",fill:"#1F9CF0"})}),t("g",{style:{mixBlendMode:"overlay"},opacity:"0.25",children:t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M70.8511 99.3171C72.4261 99.9306 74.2221 99.8913 75.8117 99.1264L96.4 89.2197C98.5634 88.1787 99.9392 85.9892 99.9392 83.5871V16.4133C99.9392 14.0112 98.5635 11.8217 96.4001 10.7807L75.8117 0.873695C73.7255 -0.13019 71.2838 0.115699 69.4527 1.44688C69.1912 1.63705 68.942 1.84937 68.7082 2.08335L29.2943 38.0414L12.1264 25.0096C10.5283 23.7964 8.29285 23.8959 6.80855 25.246L1.30225 30.2548C-0.513334 31.9064 -0.515415 34.7627 1.29775 36.4169L16.1863 50L1.29775 63.5832C-0.515415 65.2374 -0.513334 68.0937 1.30225 69.7452L6.80855 74.754C8.29285 76.1042 10.5283 76.2036 12.1264 74.9905L29.2943 61.9586L68.7082 97.9167C69.3317 98.5405 70.0638 99.0104 70.8511 99.3171ZM74.9544 27.2989L45.0483 50L74.9544 72.7012V27.2989Z",fill:`url(#${a})`})})]}),i("defs",{children:[i("filter",{id:o,x:"-8.39411",y:"15.8291",width:"116.727",height:"92.2456",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[t("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),t("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"}),t("feOffset",{}),t("feGaussianBlur",{stdDeviation:"4.16667"}),t("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"}),t("feBlend",{mode:"overlay",in2:"BackgroundImageFix",result:"effect1_dropShadow"}),t("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow",result:"shape"})]}),i("filter",{id:s,x:"60.4167",y:"-8.07558",width:"47.9167",height:"116.151",filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[t("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),t("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"}),t("feOffset",{}),t("feGaussianBlur",{stdDeviation:"4.16667"}),t("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"}),t("feBlend",{mode:"overlay",in2:"BackgroundImageFix",result:"effect1_dropShadow"}),t("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow",result:"shape"})]}),i("linearGradient",{id:a,x1:"49.9392",y1:"0.257812",x2:"49.9392",y2:"99.7423",gradientUnits:"userSpaceOnUse",children:[t("stop",{stopColor:"white"}),t("stop",{offset:"1",stopColor:"white",stopOpacity:"0"})]})]})]})}var o=/^#[0-9a-fA-F]{3,8}$/,s=/^(?:rgba?|hsla?|oklch)\([^)]+\)$/,a=new Set(["black","white","red","blue","green","yellow","orange","purple","pink","gray","grey","cyan","magenta","brown","navy","teal","maroon","olive","silver","aqua","fuchsia","lime"]);function d(e){let t=e.trim();return o.test(t)||s.test(t)||a.has(t.toLowerCase())}function h(e,i){return t("span",{style:{display:"inline-block",width:10,height:10,backgroundColor:e,border:"1px solid rgba(0,0,0,0.15)",borderRadius:2,verticalAlign:"middle",marginRight:3}},i)}function p(e){let i=e.split(/(?<![^\s([{])(@(?:codex|claude))(?=$|[\s.,!?:;)\]}])/gi);return 1===i.length?e:i.map((e,i)=>i%2?t("strong",{"data-popmelt-tool-mention":!0,children:e},i):e)}function c(e){let r,o=[],s=/(`[^`]+`)|(\*\*\*(.+?)\*\*\*)|(\*\*(.+?)\*\*)|(\*(.+?)\*)|(_([^_]+?)_)|(\[([^\]]+)\]\(([^)]+)\))|(#[0-9a-fA-F]{3,8})(?![0-9a-fA-F])|((?:rgba?|hsla?|oklch)\([^)]+\))/g,a=0;for(;null!==(r=s.exec(e));){if(r.index>a&&o.push(p(e.slice(a,r.index))),r[1]){let e=r[1].slice(1,-1);d(e)&&o.push(h(e,`sw-${r.index}`)),o.push(t("code",{style:{fontFamily:l,fontSize:"0.9em",backgroundColor:"rgba(0,0,0,0.06)",padding:"1px 4px",borderRadius:2},children:e},r.index))}else if(void 0!==r[3])o.push(t("strong",{children:t("em",{children:r[3]})},r.index));else if(void 0!==r[5])o.push(t("strong",{children:r[5]},r.index));else if(void 0!==r[7])o.push(t("em",{children:r[7]},r.index));else if(void 0!==r[9])o.push(t("em",{children:r[9]},r.index));else if(void 0!==r[11]&&void 0!==r[12]){let e=r[12],s=!/^https?:\/\/|^mailto:/i.test(e),a=s?`vscode://file/${e}`:e;s?o.push(i("a",{href:a,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline",whiteSpace:"nowrap",backgroundColor:"rgba(0,0,0,0.06)",padding:"1px 4px",borderRadius:2,fontFamily:l,fontSize:"0.9em"},children:[r[11],t(n,{})]},r.index)):o.push(t("a",{href:a,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"},children:r[11]},r.index))}else void 0!==r[13]?(o.push(h(r[13],`sw-${r.index}`)),o.push(r[13])):void 0!==r[14]&&(o.push(h(r[14],`sw-${r.index}`)),o.push(r[14]));a=r.index+r[0].length}return a<e.length&&o.push(p(e.slice(a))),o}function f(e){let i=e.split("\n"),r=[],n=0;for(;n<i.length;){let e=i[n];if(e.trimStart().startsWith("```")){let e=[];for(n++;n<i.length&&!i[n].trimStart().startsWith("```");)e.push(i[n]),n++;n++,r.push(t("pre",{style:{fontFamily:l,fontSize:"0.9em",lineHeight:1.4,backgroundColor:"rgba(0,0,0,0.04)",padding:"6px 8px",margin:"4px 0",overflowX:"auto",whiteSpace:"pre"},children:e.join("\n")},r.length));continue}if(/^(-{3,}|\*{3,}|_{3,})\s*$/.test(e)){r.push(t("hr",{style:{border:"none",borderTop:"1px solid rgba(0,0,0,0.1)",margin:"6px 0"}},r.length)),n++;continue}let o=e.match(/^(#{1,4})\s+(.+)/);if(o){let e=o[1].length,i={1:16,2:14,3:13,4:12};r.push(t("div",{style:{fontWeight:700,fontSize:i[e]??12,margin:"8px 0 2px"},children:c(o[2])},r.length)),n++;continue}if(e.trimStart().startsWith("|")&&e.trimEnd().endsWith("|")){let e=[];for(;n<i.length&&i[n].trimStart().startsWith("|")&&i[n].trimEnd().endsWith("|");)e.push(i[n]),n++;let l=e=>/^\|[\s\-:|]+\|$/.test(e),o=e.filter(e=>!l(e)),s=e=>e.split("|").slice(1,-1).map(e=>e.trim()),a=e=>/^\*\*.+\*\*$/.test(e)||/^__.+__$/.test(e),d=o.map(s),h=d.length>1&&d.slice(1).every(e=>e[0]&&a(e[0])),p=d.length>0&&d[0].every(e=>a(e));r.push(t("div",{style:{overflowX:"auto",margin:"4px 0",paddingBottom:4},children:t("table",{style:{borderCollapse:"separate",borderSpacing:0,fontSize:"0.95em",width:"max-content",minWidth:"100%"},children:t("tbody",{children:o.map((e,i)=>t("tr",{children:s(e).map((e,l)=>t(0===i?"th":"td",{style:{border:"1px solid rgba(0,0,0,0.1)",padding:"3px 6px",textAlign:"left",fontWeight:0===i?600:400,minWidth:60,whiteSpace:"nowrap",...0===l&&h||0===i&&p?{position:"sticky",...0===l&&h?{left:0}:{},...0===i&&p?{top:0}:{},background:"#fff",zIndex:0===l&&h&&0===i&&p?2:1}:{}},children:c(e)},l))},i))})})},r.length));continue}if(e.match(/^(\s*)([-*])\s+(.+)/)){let e=[];for(;n<i.length;){let t=i[n].match(/^\s*[-*]\s+(.+)/);if(t)e.push(t[1]),n++;else{if(!(e.length>0&&i[n].match(/^\s+\S/))||i[n].match(/^\s*\d+\.\s/)||i[n].match(/^\s*[-*]\s+/))break;e[e.length-1]+=" "+i[n].trim(),n++}}r.push(t("ul",{style:{margin:0,paddingLeft:20,listStyleType:"disc",display:"flex",flexDirection:"column",gap:8,fontSize:"inherit",lineHeight:"inherit"},children:e.map((e,i)=>t("li",{children:c(e)},i))},r.length));continue}let s=e.match(/^(\s*)(\d+)\.\s+(.+)/);if(s){let e=s[1].length,l=parseInt(s[2],10)||1,o=[],a=null;for(;n<i.length;){let t=i[n],l=t.match(/^(\s*)(\d+)\.\s+(.+)/);if(l&&l[1].length===e)a=[l[3]],o.push(a),n++;else if(a&&""===t.trim())n++;else if(o.length>0&&i[n].match(/^\s+\S/)&&!i[n].match(/^\s*\d+\.\s/)&&!i[n].match(/^\s*[-*]\s+/))a.push(i[n].trim()),n++;else if(a&&/^(Eval|Checks|Sources|Rationale|Prompt|Assertions?|Reason|Why|Expected|Notes?):/i.test(t.trim()))a.push(t.trim()),n++;else{if(!(a&&a.length>1&&t.trim())||t.match(/^(#{1,4})\s+/)||t.trimStart().startsWith("|")||t.match(/^\s*[-*]\s+/)||t.match(/^\s*\d+\.\s+/)||/^(\*\*)?[A-Z][A-Za-z /&-]{2,40}(\*\*)?$/.test(t.trim()))break;a.push(t.trim()),n++}}r.push(t("ol",{start:l,style:{margin:0,paddingLeft:20,listStyleType:"decimal",display:"flex",flexDirection:"column",gap:8,fontSize:"inherit",lineHeight:"inherit"},children:o.map((e,i)=>t("li",{children:t("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.map((e,i)=>t("div",{children:c(e)},i))})},i))},r.length));continue}""!==e.trim()?(r.push(t("div",{style:{fontSize:"inherit",lineHeight:"inherit"},children:c(e)},r.length)),n++):n++}return t("div",{style:{display:"flex",flexDirection:"column",fontSize:"inherit",gap:8,lineHeight:"inherit"},children:r})}var m={color:"var(--popmelt-thread-primary)",fontSize:14,letterSpacing:"0.14px",lineHeight:1.3,wordBreak:"break-word"};function u({text:i}){return t("div",{"data-popmelt-response-text":"",style:m,children:t(e,{children:f(i)})})}export{p as a,f as b,m as c,u as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{b as e}from"./chunk-L6S66APQ.mjs";import{K as t,D as o,H as i,I as n,E as a,L as s,M as r}from"./chunk-FJWWBKCQ.mjs";import{c as d}from"./chunk-I6FJ533W.mjs";import{f as c}from"./chunk-AAMUU2QA.mjs";import{v as l}from"./chunk-LH7HKUCK.mjs";import{a as m}from"./chunk-B4DYUYX4.mjs";var f="__popmelt_code_preview";function p(e,t){let o=new URL(e,t);if(o.origin!==new URL(t).origin||!/^https?:$/.test(o.protocol))throw new Error("Code previews must use the same application origin");return o.hash="",o.searchParams.delete("popmelt"),o.searchParams.set(f,"1"),o.href}function u(e,t){return!!new URL(location.href).searchParams.has(f)&&(parent===window||(window.__POPMELT_CODE_PREVIEW__?.dispose(),window.__POPMELT_CODE_PREVIEW__=h(e,t)),!0)}function h(f,p){let u,h,w=new Set,_=m,M="",E=!1,v=0,P=new Map,b=()=>{for(let[e,t]of P)null===t?e.removeAttribute("data-pm"):e.setAttribute("data-pm",t);P.clear()},g=new d(p?.get()??[]),y=()=>{for(let e of _.annotations)e.target&&g.resolve(e.target)},L=(e=_.domModifications)=>{g.applyCanvasSamples(_.canvasSamples),t(e.filter(e=>!w.has(e.id))),o(_.styleModifications),i(_.textModifications),y();for(let e of _.annotations){let t=e.linkedSelector?.match(/^\[data-pm="([^"]+)"\]$/)?.[1];if(!t)continue;let o=l(e.linkedSelector,e.elements?.[0]);o&&(P.has(o)||P.set(o,o.getAttribute("data-pm")),o.setAttribute("data-pm",t))}},A=new MutationObserver(e=>{e.some(e=>e.addedNodes.length)&&(cancelAnimationFrame(v),v=requestAnimationFrame(()=>{A.disconnect(),L(),I()}))}),I=()=>A.observe(document.body,{childList:!0,subtree:!0}),C=()=>{let e=g;e.whenReady().then(()=>{!E&&g===e&&(y(),document.dispatchEvent(new Event("popmelt-subjects-ready")))})},O=p?.subscribe(()=>{g.destroy(),g=new d(p.get()),g.applyCanvasSamples(_.canvasSamples),y(),C()});C();let S={dispose(){E||(E=!0,u?.(),A.disconnect(),O?.(),g.destroy(),cancelAnimationFrame(v),window.removeEventListener("pagehide",S.dispose),window.__POPMELT_CODE_PREVIEW__===S&&delete window.__POPMELT_CODE_PREVIEW__,n(_.textModifications),a(_.styleModifications,!0),r(_.domModifications),b())},source:f,getSubjects:()=>g,update(t){if(E)throw new Error("Preview runtime closed");if(t.draft.source&&t.draft.source.sourceId!==f.sourceId)throw new Error("This draft belongs to a different source");let o=JSON.stringify([t.planeId,t.draft.revision,t.draft.source?.sourceId,t.draft.source?.revision]);if(M===o)return;let i=structuredClone(t.draft.state??m),r=e=>!e.pathname||c(e.pathname)===c(location.pathname),d={...i,annotations:i.annotations.filter(r),styleModifications:i.styleModifications.filter(r),textModifications:i.textModifications.filter(r),domModifications:i.domModifications.filter(r)};A.disconnect(),n(_.textModifications),a(_.styleModifications,!0);let l=s(_.domModifications,d.domModifications);b(),u?.(),h!==t.planeId&&w.clear(),h=t.planeId,_=d,u=e(d.domModifications.filter(e=>!w.has(e.id)),c(location.pathname),!1,e=>{for(let t of e)w.add(t)}),L(l),I(),M=o}};return I(),window.addEventListener("pagehide",S.dispose,{once:!0}),S}export{p as a,u as b,h as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,b as r}from"./chunk-WDSFOF2E.mjs";import{c as t,e as o}from"./chunk-NXTWB3A7.mjs";import{d as a,e as n,f as i}from"./chunk-IW7V7WNL.mjs";import{b as s,c as l,e as p,f as c}from"./chunk-SQA27YGA.mjs";import{existsSync as d}from"fs";import{dirname as h,join as g,resolve as f}from"path";import{createHash as m}from"crypto";import{homedir as u}from"os";import{mkdir as w,realpath as v,symlink as y}from"fs/promises";import{basename as b,join as S,relative as E,isAbsolute as P,sep as T}from"path";var j="popmelt-plane-renderer",I=[".env",".env.*","*.{crt,pem}","**/.git","**/.git/**"];function x(e){let r=e?`**/${b(e)}/**`:"**";return[r+"/.popmelt",r+"/.popmelt/**"]}function _(e,r,t){let{publicDir:o,base:a}=e.config;o&&e.middlewares.use(a,async(e,a,n)=>{try{let n=decodeURIComponent(new URL(e.url??"/","http://localhost").pathname),i=await v(S(o,n)),s=E(r,i);if(s.split(T).includes(".popmelt")||t&&(".."===s||s.startsWith(".."+T)||P(s)))return a.statusCode=403,void a.end()}catch(e){let r=e.code;if("ENOENT"!==r&&"ENOTDIR"!==r)return n(e)}n()})}function O(e){return[{tag:"script",injectTo:"head-prepend",children:"window.__POPMELT_PARTICIPANTS__="+JSON.stringify(e).replace(/</g,"\\u003c")}]}function R(r){let s,l,p,c,d=new Map,h=async()=>{let e=[...d.values()];d.clear();let r=[s?.lan,s?.tunnel];s&&(delete s.lan,delete s.tunnel),await Promise.all([...r.map(e=>e?.close()),...e.map(e=>e.catch(()=>{}))])},g=()=>p??=(async()=>{if(l?.cancelBrowserLaunch(),s)try{await h(),await s.planeApps.close()}finally{await s.bridge.close()}})(),f=async()=>{if(await c,!l)throw new Error("Plane session has no bootstrap.");return{...await l.read(),lanInviteOrigin:s?.tunnel?.origin??s?.lan?.origin}};return{room:()=>{if(!s)throw new Error("Start the local Vite session first.");return s},close:g,read:f,async configureServer(b){let R=b.config.server.host||"localhost",A=r.origin??`http://${"::1"===R?"[::1]":R}:${b.config.server.port}`,N=new URL(A);if(!["127.0.0.1","localhost","[::1]"].includes(N.hostname)||"http:"!==N.protocol||N.origin!==A||"/"!==b.config.base)throw new Error("Local plane sessions need a loopback HTTP origin and a root-mounted host app.");if(!b.httpServer)throw new Error("Local plane sessions require a listening Vite dev server.");if(!0===b.config.server.host||"string"==typeof b.config.server.host&&!["127.0.0.1","localhost","::1"].includes(b.config.server.host)||b.config.server.https||b.config.server.port!==Number(N.port||80))throw new Error("Match the session origin to the local Vite host and port.");r.origin&&(b.config.server.strictPort=!0);let k=await v(b.config.root),D=S(k,".popmelt","planes"),L=r.directory??D;await w(L,{recursive:!0,mode:448});let $=E(k,await v(L));if($!==S(".popmelt","planes")&&".."!==$&&!$.startsWith(".."+T)&&!P($))throw new Error("Use .popmelt/planes or a directory outside the served project.");if(!r.prepare){let e=await v(S(k,"node_modules")).catch(e=>{if("ENOENT"!==e.code)throw e});if(e){let r=S(L,"node_modules");try{await y(e,r,"junction")}catch(t){if("EEXIST"!==t.code||await v(r)!==e)throw t}}}let M=new Map,W=await a({projectRoot:k,directory:L,previousDirectory:void 0===r.directory?S(u(),".popmelt-planes",m("sha256").update(k).digest("hex")):void 0,async startApp({directory:e,basePath:t,checkoutRoot:o}){let a,p,c,d=1,h=1,g=0,f=!1,u=(r,t)=>{n(t)&&(h++,M.delete(e))},w=()=>{if(r.prepare||g===h)return;if(a)return a;let t=M.get(e);if(t&&Date.now()<t.until)throw t.error;return a=(async()=>{for(;g!==h;){let r=h,t=await i(e,o,k,e=>{b.watcher.add(e)});if(c&&(t.installed||t.graph!==p)&&(f=!0),f&&c){let e=c.watcher;if(await c.restart(!0),e===c.watcher)throw new Error("Could not restart the plane after its dependency install.");d++,f=!1}p=t.graph,M.delete(e),g=r}})().catch(r=>{throw M.set(e,{until:Date.now()+15e3,error:r}),b.config.logger.error("Plane dependency setup failed: "+(r instanceof Error?r.message:String(r))),r}).finally(()=>{a=void 0}),a};r.prepare?await r.prepare(e):await w();let v=x(o),y={name:j,enforce:"post",config(e){e.server?.fs&&(e.server.fs.allow=[o])},configureServer(r){_(r,o,!0),o!==e&&r.watcher.add(o),r.watcher.on("all",(e,r)=>{d++,u(0,r)})},transformIndexHtml:async()=>O({...await l.read(t),lanInviteOrigin:s?.tunnel?.origin??s?.lan?.origin})},E=await r.createServer({root:e,base:t,mode:b.config.mode,plugins:[y],cacheDir:S(L,"cache",m("sha256").update(e).digest("hex")),server:{fs:{strict:!0,allow:[o],deny:[...I,...v]},host:"127.0.0.1",port:0,strictPort:!1,open:!1,https:void 0,hmr:!1,watch:{ignored:[...v,"**/.git/**"]}}});try{if(E.config.root!==e||E.config.base!==t||E.config.server.https||E.config.server.proxy)throw new Error("Plane Vite servers require their assigned root and base, HTTP and local assets. Use a custom app runner for backend proxies.");await E.listen();let r=E.httpServer?.address();if(!r||"string"==typeof r||"127.0.0.1"!==r.address)throw new Error("Expected an isolated loopback Vite server.");return c=E,b.watcher.on("all",u),h++,{origin:"http://127.0.0.1:"+r.port,version:()=>String(d),ready:w,async close(){b.watcher.off("all",u),await(a?.catch(()=>{})),await E.close()}}}catch(e){throw await E.close(),e}}});try{let a=async o=>{if(!s||p)throw new Error("The session has closed.");let a=s;if(a[o])return a[o].inviteOrigin();let n=d.get(o);return n||(n=(async()=>{let i=r.lan?.build??r.tunnel?.build??(await e(k)).build,s=await t(a.bridge,W,{build:i,address:"lan"===o?r.lan?.address:void 0,quickTunnel:"tunnel"===o});if(d.get(o)!==n)throw await s.close(),new Error("Sharing stopped.");return a[o]=s,s})().finally(()=>{d.get(o)===n&&d.delete(o)}),d.set(o,n)),(await n).inviteOrigin()},{startPopmelt:n}=await(import("./server.mjs")),i=await n({projectRoot:k,port:r.bridgePort,devOrigin:A,experimentalEventTransport:r.experimentalEventTransport,manageLease:!1,participantSessions:{planeApps:W,guestOrigin:a,stopGuestSharing:h}});s={planeApps:W,bridge:i};let m=async e=>{l?.cancelBrowserLaunch(),l=await o({bridge:i,projectRoot:k,origin:e,guestInvites:r.tunnel&&!r.lan?"tunnel":"lan",planeApps:W})};await m(A),r.origin||b.httpServer.once("listening",()=>{let e=b.httpServer?.address();e&&"string"!=typeof e&&e.port!==Number(N.port)&&(N.port=String(e.port),c=m(N.origin),c.catch(e=>b.config.logger.error(String(e))))}),r.lan&&await a("lan"),r.tunnel&&(await f()).tunnelAvailable&&await a("tunnel"),b.middlewares.use("/__popmelt/host",(e,r,t)=>{Promise.resolve(c).then(()=>l.hostEntry(e,r)).catch(t)}),b.middlewares.use((e,r,t)=>{Promise.resolve(c).then(()=>l.planeMiddleware(e,r,t)).catch(t)}),_(b,k,!1),b.watcher.on("all",(e,r)=>{/(^|[\\/])(?:\.popmelt|\.git|node_modules)([\\/]|$)/.test(r)||W.sourceChanged()}),b.httpServer.once("close",()=>{g().catch(e=>b.config.logger.error(String(e)))})}catch(e){throw s?await g():await W.close(),e}}}}function A(e){let r=R(e);return{name:"popmelt-local-participant-planes",apply:(e,r)=>"serve"===r.command&&!e.plugins?.some(e=>e&&"name"in e&&e.name===j),config:()=>({server:{fs:{strict:!0,deny:[...I,...x()]},watch:{ignored:x()}}}),api:{room:r.room},configureServer:r.configureServer,transformIndexHtml:async()=>O(await r.read()),closeBundle:r.close}}var N="@popmelt.com/core/browser";function k(t,o){let a,n=t?.basePath??"/popmelt",i={port:null,projectId:null},m=!1,u="virtual:popmelt/bridge",w=`\0${u}`;return{name:"popmelt",api:{ownsDevBridge:!1!==t?.bridge,room(){if(!a)throw new Error("Independent planes are unavailable for this server.");return a.room()}},config(e,{command:r,isPreview:t}){m="serve"===r&&!t;let o=e?.plugins?.flat(1/0).some(e=>"popmelt-plane-renderer"===e?.name||"popmelt-local-participant-planes"===e?.name);if(m&&!o)return{server:{fs:{strict:!0,deny:[".env",".env.*","*.{crt,pem}","**/.git","**/.git/**","**/.popmelt","**/.popmelt/**"]},watch:{ignored:["**/.popmelt/**"]}}}},async configResolved(e){if(!m||!(await e.createResolver({asSrc:!1,scan:!0})(N).catch(()=>{}))?.replaceAll("\\","/").includes("/node_modules/"))return;let{include:r,exclude:t,noDiscovery:o,disabled:a}=e.optimizeDeps;o||!0===a||"dev"===a||r?.includes(N)||t?.some(e=>e===N||N.startsWith(e.endsWith("/")?e:`${e}/`))||(e.optimizeDeps.include=[...r??[],N])},resolveId(e){if(e===u)return w},load:e=>e!==w?void 0:`${i.bootstrap?`if(typeof window !== 'undefined')window.__POPMELT_PARTICIPANTS__??=${JSON.stringify(i.bootstrap)};`:""}export const bridgeUrl = ${JSON.stringify(null===i.port?null:`http://localhost:${i.port}`)}; export const projectId = ${JSON.stringify(i.projectId)};`,async closeBundle(){await(i.close?.())},async configureServer(c){if(c.config?.plugins?.some(e=>"popmelt-plane-renderer"===e.name||"popmelt-local-participant-planes"===e.name))return;let m=c,u=t?.projectRoot??c.config?.root;if(!1!==t?.bridge&&!process.env.POPMELT_BRIDGE_URL&&!o&&function(e,r){let t=e.config;if(!t||!e.httpServer||!t.root||"/"!==t.base||"custom"===t.appType||t.server.middlewareMode||t.server.https||t.server.proxy||t.server.host&&!["127.0.0.1","localhost","::1"].includes(String(t.server.host))||r?.projectRoot&&f(r.projectRoot)!==t.root||!d(g(t.root,"index.html")))return!1;let o=t.root;for(;!d(g(o,".git"));){let e=h(o);if(o===e)return!1;o=e}return!0}(m,t))try{let r=R({createServer:(await e(m.config.root)).createServer,bridgePort:t?.port,experimentalEventTransport:t?.experimentalEventTransport});await r.configureServer(m),a=r;let o=a.room();i={port:o.bridge.port,projectId:o.bridge.projectId,close:a.close},console.info("[popmelt] Pair and Share: private host link for another browser or a headless session in .popmelt/participant-host-link.json.")}catch(e){m.config.logger.warn("[popmelt] Starting a shared preview because independent planes could not start: "+String(e))}a||(c.config?.publicDir&&c.config.root&&_(m,c.config.root,!1),i=await s(t,c,5173,u&&!o?r(u,m):void 0,o)),await l(i,c),c.middlewares.use(p(n,()=>i))},transformIndexHtml(){if(null===i.port)return;let e=e=>[{tag:"script",attrs:{type:"text/javascript"},children:c(e),injectTo:"head-prepend"}];return a?a.read().then(r=>e({...i,bootstrap:r})):e(i)}}}export{A as a,k as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";function t(t){if(0===t.length)return{x:0,y:0,width:0,height:0};let h=t.map(t=>t.x),a=t.map(t=>t.y),i=Math.min(...h),e=Math.max(...h),n=Math.min(...a);return{x:i,y:n,width:e-i,height:Math.max(...a)-n}}export{t as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{a as e}from"./chunk-FHCKFQBY.mjs";import{a as t}from"./chunk-APP5IYTE.mjs";import{i as r,J as n,p as l,a as o,n as i,z as a,G as s,H as f,D as c,q as u}from"./chunk-5IZHN3A7.mjs";import{a as p,b as d}from"./chunk-WP2SHSCG.mjs";import{v as m,l as h,k as g}from"./chunk-LH7HKUCK.mjs";var y='[role="img"], [role="group"][aria-label], [role="group"][aria-labelledby]';function b(e){let t=e?.closest(y);return t&&"canvas"!==t.localName&&t.querySelector("canvas")?t:null}function w(e,t){let r=t?.querySelector("canvas")?t:b(e);if(!r||r===e)return null;let n=r.querySelectorAll("canvas");if(1!==n.length)return null;let l=n[0].getBoundingClientRect(),o=e.getBoundingClientRect();return l.width<=0||l.height<=0?null:o.left<=l.left+1&&o.top<=l.top+1&&o.right>=l.right-1&&o.bottom>=l.bottom-1?r:null}function S(e){let t=m(e.selector,e.element),r=function(e,t=m(e.selector,e.element)){let r=e.element;if("canvas"!==r?.tagName&&"svg"!==r?.tagName&&!t?.closest("svg,canvas"))return t;let n=b(t);if(n)return n;if(t)return t;let l=r?.selector,o=l?.lastIndexOf(" > ")??-1;if(l&&o>=0)try{let e=b(h(l.slice(0,o)));if(e&&(!r?.reactComponent||p(e)?.name===r.reactComponent))return e}catch{}if(!r?.reactComponent||r.frameContext?.length||l?.includes(" >>> "))return null;let i=g().flatMap(e=>Array.from(e.querySelectorAll(y)).filter(e=>e.querySelector("canvas")&&p(e)?.name===r.reactComponent));return 1===i.length?i[0]:null}(e,t),n=e.element?.reactComponent,l=t&&(n?function(e,t){let r=d(e).findLast(e=>e.name===t)?.fiber;if(!r?.child)return null;let n=[r.child],l=null;for(;n.length;){let e=n.pop();if(4===e.tag)return null;e.sibling&&n.push(e.sibling);let t=e.stateNode;if((1===t?.nodeType||3===t?.nodeType)&&(!l&&1===t.nodeType&&(l=t),!l?.contains(t)))return null;e.child&&n.push(e.child)}return l?.contains(e)?l:null}(t,n):b(t));return{element:t,component:l,legacy:r,legacyScene:t&&w(t,l)}}function E(e,t,r){let n="component"===t?e.component:"element"===t?e.element:r&&e.legacyScene||e.legacy;return n?.isConnected&&n.parentElement&&!n.matches("body,html")&&!n.closest("[data-devtools]")?n:null}var v=["font-family","font-size","font-weight","font-style","font-stretch","font-variation-settings","font-feature-settings","line-height","letter-spacing","white-space","overflow-wrap","word-break","flex-wrap","color"];function x(e){return e.trim().replace(/^(['"])(.*)\1$/,"$2").toLowerCase()}function*N(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode(e){if(e.nodeType===Node.TEXT_NODE)return e.textContent?.trim()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP;let t=e;return t.matches("script,style,noscript,template,[hidden],[data-devtools],[data-popmelt-root]")?NodeFilter.FILTER_REJECT:t.matches("input,textarea,select")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=new Set;for(let e=t.nextNode();e;e=t.nextNode()){let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;!t||r.has(t)||(r.add(t),yield[t,e.nodeType===Node.TEXT_NODE?e.textContent.trim():""])}}function C(e){let t=[],r=new Set;for(let[n,l]of N(e)){let o=getComputedStyle(n),i=n.closest("button,a,label"),a=(i&&e.contains(i)?i:n).localName,{fontFamily:s,fontWeight:f,fontSize:c}=o,u=JSON.stringify([a,s,f,c]);if(s&&!r.has(u)&&(r.add(u),t.push({tag:a,text:l.slice(0,64),family:s,weight:f,size:c}),12===t.length))break}return t}function T(e,t){let r=e.ownerDocument,n=[];function l(e){if(!e||e.disabled)return;let t;try{t=e.cssRules}catch{return}o(t,e.href??r.baseURI)}function o(e,r){for(let i of e)if(i.type===CSSRule.FONT_FACE_RULE){let{style:e}=i;if(!t.has(x(e.getPropertyValue("font-family"))))continue;let l=i.cssText.replace(/url\("([^"]*)"\)|url\('([^']*)'\)|url\(([^)]*)\)/gi,(e,t,n,l)=>{try{return"url("+JSON.stringify(new URL(t??n??l.trim(),r).href)+")"}catch{return e}});n.push(l)}else i.type===CSSRule.IMPORT_RULE?l(i.styleSheet):"cssRules"in i&&o(i.cssRules,r)}let i=[r];for(let t=e.getRootNode();"host"in t;t=t.host.getRootNode())i.push(t);for(let e of i)for(let t of[...e.styleSheets,...e.adoptedStyleSheets??[]])l(t);return n}async function I(e,t){let r=function(e,t){let r=new Set([t]);for(let[t]of N(e))t!==e&&r.add(getComputedStyle(t).fontFamily);let n=new Set;for(let e of r)for(let t of e.matchAll(/\s*("[^"]*"|'[^']*'|[^,]+)\s*(?:,|$)/g))n.add(x(t[1]));return n}(e,getComputedStyle(e).fontFamily),n=T(e,r).join("\n"),l=new Set(Array.from(n.matchAll(/url\("([^"]+)"\)/g),e=>e[1])),o=n;return await Promise.all([...l].map(async e=>{if(!e.startsWith("data:"))try{let r=await fetch(e,{signal:t,credentials:"same-origin"});if(!r.ok)return;let n=await r.blob(),l=await new Promise((e,t)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=t,r.readAsDataURL(n)});o=o.replaceAll(JSON.stringify(e),JSON.stringify(l))}catch{}})),o}var k=/^(?:@[a-zA-Z][\w-]{0,63}|~?(?:0|[1-9]\d{0,3})(?:\.(?:0|[1-9]\d{0,3})){0,31}|)$/;function R(e,t){let r="text"===t?e.replace(/\/text\/(?:0|[1-9]\d{0,3})$/,""):e;return k.test(r)}function A(e){if(e.matches('svg, img, [role="img"]'))return!0;if(e.childElementCount||"http://www.w3.org/1999/xhtml"!==e.namespaceURI)return!1;let t=e.ownerDocument.defaultView?.getComputedStyle(e).maskImage;return!!t&&"none"!==t}function O(e){let t=e.getAttribute("data-popmelt-subject-label")||e.getAttribute("data-explore-part");if(t)return t.slice(0,80);let r=e.closest('button, a[href], [role="button"], [role="link"]');if(r===e)return e.matches('a[href], [role="link"]')?"link":"button";let n=e.getAttribute("aria-label");if(A(e)){let t=n||e.getAttribute("alt")||e.querySelector(":scope > title")?.textContent;if(t)return t.slice(0,80);if(r){let t=Array.from(r.querySelectorAll("*")).filter(A);if(t.length>1)return"icon "+(t.indexOf(e)+1)}return"icon"}let l=Array.from(e.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.textContent).join(" ").trim();return r&&l?"label":(n||l||e.localName).slice(0,80)}function j(e,t){let r=new Map;for(let n of[...e,...t]){let e=n.part+":"+n.property,t=r.get(e)?.from??n.from;t===n.to?r.delete(e):(r.delete(e),r.set(e,{...n,from:t}))}return[...r.values()]}function F(e){let t=Object.create(null);for(let{batchId:r,option:n,part:l,property:o,to:i}of e){let e=t[r]??(t[r]=Object.create(null)),a=e[n]??(e[n]=Object.create(null));(a[l]??(a[l]=Object.create(null)))[o]=i}return t}function _(e){if(!e||"object"!=typeof e)throw new Error("Invalid Steer edit.");let{batchId:n,option:l,part:o,property:a,from:s,to:f,sticker:c}=e;if("string"!=typeof n||"number"!=typeof l||!Number.isInteger(l)||"string"!=typeof o||"string"!=typeof a||"string"!=typeof s||"string"!=typeof f||("text"===a||"paragraphs"===a)&&void 0!==c)throw new Error("Invalid Steer edit.");"paragraphs"===a?(t(s),t(f)):"text"!==a&&$({[a]:f});let p={batchId:n,option:l,part:o,property:a,from:s,to:f};if(void 0===c)return p;let{family:d,subproperty:m,step:h,axisSteps:g}=c;if(!r.includes(d)||u(d,m)!==m||!i(d,m).includes(h))throw new Error("Invalid Steer dimension.");let y={family:d,subproperty:m,step:h};if(void 0===g)return{...p,sticker:y};let b=i("transform","translate");if("transform"!==d||"translate"!==m||!b.includes(g.x)||!b.includes(g.y))throw new Error("Invalid Steer translation.");return{...p,sticker:{...y,axisSteps:{x:g.x,y:g.y}}}}var L=new Map;function P(e,t){L.has(e)||L.set(e,new Set),L.get(e).add(t)}for(let e of r){let t=n(e);t&&P("display",t);for(let t of l(e))for(let r of"color"===t?o:[t]){let t=i(e,r);for(let n of t){let l=a(e,r);P(l,s(e,n,r));for(let t of f(e,r,n))P(t.property,t.value);if("border"===e&&l.endsWith("width")&&P(c(r),"solid"),"translate"===l)for(let e of t)P(l,4*Number(n)+"px "+4*Number(e)+"px")}}}function U(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Invalid Steer draft.");return Object.entries(e)}function $(e){return Object.fromEntries(U(e).map(([e,t])=>{if("string"!=typeof t||!L.get(e)?.has(t))throw new Error("Unsupported Steer declaration: "+e);return[e,t]}))}function q(e,r){if(void 0===r)return e;let n=structuredClone(e);for(let[e,l]of U(r)){let r=n.messages.find(t=>t.batch?.id===e)?.batch;if(!r)throw new Error("Steer draft refers to an unknown batch.");for(let[e,n]of U(l)){let l=/^[0-5]$/.test(e)&&r.options[Number(e)];if(!l)throw new Error("Steer draft refers to an unknown option.");for(let[e,r]of U(n)){if("fixture"in l){if(!U(r).every(([t])=>R(e,t)))throw new Error("Invalid fixture part.");let{text:n,paragraphs:l,...o}=Object.fromEntries(U(r));if(void 0!==n&&"string"!=typeof n)throw new Error("Invalid fixture text.");if(void 0!==l){if("string"!=typeof l)throw Error("Invalid paragraph draft.");t(l)}$(o);continue}if(!/^(?:[0-7](?:\.[0-7]){0,3})?(?:\/label)?$/.test(e))throw new Error("Invalid specimen path.");let[n,o]=e.split("/"),i=l.root;for(let e of n?n.split("."):[])i=i?.children?.[Number(e)];if(!i||o&&(!i.label||"text"===i.kind))throw new Error("Steered element no longer exists.");let{text:a,...s}=Object.fromEntries(U(r));if(void 0!==a){if("string"!=typeof a||!o&&"text"!==i.kind)throw new Error("Invalid specimen text.");i.label=a}if(Object.keys(s).length){let e=o?"labelStyle":"style";i[e]={...i[e],...$(s)}}}}}return n}function D(e){return[...e.original?.runnable?[e.original.runnable]:[],...e.options]}function H(e,t){if(!e||e.target)return;let r=e.elements?.find(t=>t.selector===e.linkedSelector)??e.elements?.[0],n=e.linkedSelector??r?.selector;return n?{selector:n,element:r,pathname:e.pathname??t}:void 0}var W=new RegExp(`^${e.explore}(?=\\s|$)`,"i");function z(e){let t=W.exec(e.trimStart());return!!t&&!!e.trimStart().slice(t[0].length).trim()}function J(e,t){let r=e.label?.trim().replace(/\s*[→↓]$/,"").slice(0,52),n=r?r[0].toUpperCase()+r.slice(1)+" "+e.kind:e.kind[0].toUpperCase()+e.kind.slice(1),l=e.name||n;return"label"===t?l+" label":l}export{b as a,S as b,E as c,v as d,C as e,I as f,k as g,R as h,O as i,j,F as k,_ as l,q as m,D as n,H as o,z as p,J as q};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{a as e}from"./chunk-XTOCFTVW.mjs";function t(){return{schemaVersion:1,name:"",constraints:[{id:"basis",name:"basis",kind:"layout",value:"16",parentId:null,derivative:1,scale:.75},{id:"padding",name:"padding",kind:"layout",value:"",parentId:"basis",derivative:2,scale:1},{id:"gap",name:"gap",kind:"layout",value:"16",parentId:null,derivative:1,scale:.75},{id:"radii",name:"radii",kind:"layout",value:"",parentId:null,derivative:1,scale:.75},...r(),{id:"primary",name:"primary",kind:"color",value:"oklch(65% 0.16 265)",parentId:null,derivative:0,scale:.125},{id:"secondary",name:"secondary",kind:"color",value:"",parentId:"primary",derivative:30,scale:.125},{id:"tertiary",name:"tertiary",kind:"color",value:"",parentId:"primary",derivative:60,scale:.125}],tokens:[{id:"semantic-color",name:"semantic_color",value:"@primary: 1"},{id:"ad-hoc-spacer",name:"ad-hoc-spacer",value:"@basis: 2"},{id:"ad-hoc-color",name:"ad-hoc-color",value:"#123ccc"},{id:"shadow-lg",name:"shadow-lg",value:"0 10px 15px rgba(0, 0, 0, 0.5)"}]}}function r(){return["body","heading"].flatMap(e=>[{id:`${e}-family`,name:`${e}-family`,kind:"font",group:"typography",typographyRole:e,value:"body"===e?"system-ui, sans-serif":"",parentId:"heading"===e?"body-family":null,derivative:1,scale:1},...["size","height","weight"].map(t=>({id:`${e}-${t}`,name:`${e}-${t}`,kind:"layout",group:"typography",typographyRole:e,value:"weight"===t&&"body"===e?"400":"",parentId:"size"===t?"body"===e?"basis":"body-size":"height"===t?`${e}-size`:"body"===e?null:"body-weight",derivative:"height"===t?1.5:"size"===t?2:1,scale:"weight"===t?100:.125,..."weight"===t?{scaleMode:"increment"}:{}}))])}function n(e){let t={text:"body-size",height:"body-height",weight:"body-weight"},n=e.constraints.filter(e=>t[e.id]);if(!n.length)return e;let i=[...e.constraints];for(let e of r()){if(i.some(t=>t.id===e.id))continue;let r=n.find(r=>t[r.id]===e.id);i.push(r?{...r,id:e.id,name:e.name,group:e.group,typographyRole:e.typographyRole}:e)}let o=i.filter(e=>!t[e.id]).map(e=>({...e})),a=e=>{let r=new Set([e.id]);for(;e.parentId&&t[e.parentId];){let t=i.find(t=>t.id===e.parentId);if(!t||r.has(e.parentId)){e.parentId=null,e.value="";break}if(r.add(e.parentId),e.derivative*=t.derivative,e.parentId=t.parentId,!t.parentId){try{e.value=f(p(i,e.id))}catch{e.value=t.value}e.derivative=1}}};o.filter(e=>"body"===e.typographyRole).forEach(a);for(let e of o){if(!e.parentId||!t[e.parentId])continue;let r=t[e.parentId];try{let t=p(i,e.parentId),n=p(o,r);if("layout"!==t.kind||"layout"!==n.kind||t.unit!==n.unit||!n.value||c(o,e.id,r))throw Error("Keep the original root");e.derivative*=t.value/n.value,e.parentId=r}catch{a(e)}}let s=new Map(n.map(e=>[e.name.toLowerCase(),t[e.id]]));return n.some(e=>"text"===e.id)&&(s.set("text","body-size"),s.set("size","body-size")),{...e,constraints:o,tokens:e.tokens.map(e=>({...e,value:e.value.replace(/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|url\([^)]*\)|@([\w-]+)(?::\s*[+-]?(?:\d+\.?\d*|\.\d+))?/gi,(e,t)=>{if(!t)return e;let r=s.get(t.toLowerCase());if(!r)return e;let n=e.replace(`@${t}`,`@${r}`),a=g(i,e),l=g(o,n);return!a||l&&f(a)===f(l)?n:f(a)})}))}}var i="[+-]?(?:\\d+\\.?\\d*|\\.\\d+)",o=new RegExp(`^(${i})(px|rem|em|%|vw|vh|vmin|vmax|ch)?$`,"i"),a=new RegExp(`^oklch\\(\\s*(${i})(%)?\\s+(${i})\\s+(${i})(?:deg)?\\s*\\)$`,"i"),s=e=>(e%360+360)%360,l=e=>Math.max(0,Math.min(1,e)),d=e=>Number(e.toFixed(4));function u(e,t){if("font"===e){let r=t.trim();if(!r||!/[a-z\u0080-\uffff]/i.test(r)||r.length>160||/[;{}()@]|[<>]/.test(r)||[...r].some(e=>e.charCodeAt(0)<32))throw Error("Use a font family or comma-separated font stack");return{kind:e,value:r}}if("layout"===e){let r=t.trim().match(o);if(!r||!Number.isFinite(Number(r[1]))||Number(r[1])<0)throw Error("Use a positive length, like 24px or 1.5rem");return{kind:e,value:Number(r[1]),unit:r[2]?.toLowerCase()??""}}let r=t.trim().match(a);if(!r)throw Error("Use OKLCH, like oklch(65% 0.16 265)");let n=Number(r[1])/(r[2]?100:1),i=Number(r[3]),l=Number(r[4]);if(![n,i,l].every(Number.isFinite)||n<0||n>1||i<0)throw Error("Lightness must be 0–100% and chroma cannot be negative");return{kind:e,l:n,c:i,h:s(l)}}function c(e,t,r){let n=e.find(e=>e.id===t),i=e.find(e=>e.id===r);if(!n||!i)return"Choose an existing constraint";if(n.kind!==i.kind)return"Connect constraints of the same type";if("increment"===n.scaleMode!=("increment"===i.scaleMode))return"Connect weights to weights, and lengths to lengths";let o=new Set([t]);for(;i;){if(o.has(i.id))return"That connection would create a cycle";if(o.add(i.id),!i.parentId)break;if(i=e.find(e=>e.id===i.parentId),!i)return"The parent reference is missing"}return null}function p(e,t,r=0){let n=new Set,i=t=>{if(n.has(t))throw Error("Circular reference");n.add(t);let r=e.find(e=>e.id===t);if(!r)throw Error("The parent reference is missing");if(!Number.isFinite(r.derivative))throw Error("Use a finite derivative");if(!r.parentId)return u(r.kind,r.value);let o=e.find(e=>e.id===r.parentId);if(o&&"increment"===r.scaleMode!=("increment"===o.scaleMode))throw Error("Connect weights to weights, and lengths to lengths");let a=i(r.parentId);if(a.kind!==r.kind)throw Error("Connect constraints of the same type");if("font"===a.kind)return a;if("layout"===a.kind){if(r.derivative<0)throw Error("The derivative cannot be negative");return{...a,value:a.value*r.derivative}}return{...a,h:s(a.h+r.derivative)}},o=i(t),a=e.find(e=>e.id===t);if("font"===o.kind){if(0!==r)throw Error("Font families do not have numeric steps");return o}if(!Number.isFinite(r)||!Number.isFinite(a.scale))throw Error("Use a finite step");if("layout"===o.kind){if("increment"===a.scaleMode?a.scale<=0:a.scale<0)throw Error("Use a nonnegative growth rate or a positive weight increment");let e="increment"===a.scaleMode?Math.max(0,o.value+a.scale*r):o.value*(1+a.scale)**r;if(!Number.isFinite(e))throw Error("The scaled value is too large");return{...o,value:0===r?e:Math.round(e)}}return{...o,l:l(o.l+a.scale*r)}}function f(e){return"font"===e.kind?e.value:"layout"===e.kind?`${d(e.value)}${e.unit}`:`oklch(${d(100*e.l)}% ${d(e.c)} ${d(e.h)}${void 0===e.alpha?"":` / ${d(e.alpha)}`})`}function m(e){let t=e.trim().match(new RegExp(`^@([^:@/(),]+?)(?::\\s*(${i}))?(?:\\s*/\\s*(${i}%?))?$`));return!t||!t[1].trim()||void 0===t[2]&&/\s/.test(t[1].trim())||void 0!==t[2]&&!Number.isFinite(Number(t[2]))||void 0!==t[3]&&null===h(t[3])?null:{name:t[1].trim(),step:void 0===t[2]?null:Number(t[2]),...void 0===t[3]?{}:{opacity:t[3]}}}function h(e){if(!new RegExp(`^${i}%?$`).test(e))return null;let t=parseFloat(e)/(e.endsWith("%")?100:1);return Number.isFinite(t)&&t>=0&&t<=1?t:null}function g(e,t){let r=m(t);if(!r)return null;let n=e.find(e=>e.name.toLowerCase()===r.name.toLowerCase());if(!n)return null;try{let t=p(e,n.id,r.step??0);return void 0===r.opacity?t:"color"===t.kind?{...t,alpha:h(r.opacity)}:null}catch{return null}}function v(e,t,r){let n=e.find(e=>e.id===t);if("layout"!==n?.kind)return n?.derivative??0;try{let n=p(e,t),i=p(e,r);if("layout"===n.kind&&"layout"===i.kind&&n.unit===i.unit&&0!==i.value){let e=n.value/i.value;if(Number.isFinite(e))return e}}catch{}return 1}function y(e,t){let r=f(p(e,t));return e.map(e=>e.id===t?{...e,parentId:null,value:r}:e)}function k(e,t){let r=new Set;for(let n=0;n<32;n+=1){if(r.has(e))return;if(r.add(e),e&&"object"==typeof e){let t=e;e=t.$value??t.ref;continue}if("string"!=typeof e)return;let n=e.trim(),i=n.replace(/^\{(.+)\}$/,"$1").replace(/^var\(--([^,)]+)\)$/,"$1").replace(/^var\(principles\.([^,)]+)\)$/,"$1").replace(/^principles\./,"");if(!Object.hasOwn(t,i)){if(/\b(currentcolor|inherit|initial|unset|revert|var|env|light-dark)\b/i.test(n))return;if(typeof CSS<"u"&&CSS.supports)return CSS.supports("color",n)?n:void 0;if(typeof document<"u"){let e=document.createElement("span").style;return e.color=n,e.color?n:void 0}return}e=t[i]}}var b=/^@([\w-]+)(?::\s*[+-]?(?:\d+\.?\d*|\.\d+)(?![\w.]))?(?![\w-]|\s*:)/,w=/^(?:px|rem|em|ex|ch|cap|ic|lh|rlh|vw|vh|vi|vb|vmin|vmax|[sld]v[whib]|cm|mm|q|in|pt|pc|%)$/i,I=e=>String(Number(e.toPrecision(12)));function $(e,t){if(e.length>4096||!/^calc\(/i.test(e))return null;let r=5,n=0,i=()=>{throw Error("Invalid calc expression")},o=()=>{for(;/\s/.test(e[r]??"")&&r<e.length;)r++},a=(e,t="")=>!Number.isFinite(e)||t&&!w.test(t)?i():{kind:t?"length":"number",terms:new Map([[t.toLowerCase(),e]])},s=(e,t)=>({...e,terms:new Map([...e.terms].map(([e,r])=>{let n=r*t;return Number.isFinite(n)||i(),[e,n]}))}),l=()=>{o(),++n>32&&i();try{let n=e[r];if("+"===n||"-"===n)return r++,s(l(),"-"===n?-1:1);if("("===e[r]||/^calc\(/i.test(e.slice(r))){r+="("===e[r]?1:5;let t=u();return o(),")"!==e[r++]&&i(),t}let d=e.slice(r).match(b)?.[0];if(d){r+=d.length;let e=g(t,d);if("layout"!==e?.kind)return i();let n=t.find(e=>e.name.toLowerCase()===d.slice(1).split(":")[0].trim().toLowerCase());return a(e.value,e.unit||("increment"===n?.scaleMode?"":"px"))}let c=e.slice(r).match(/^(\d+\.?\d*|\.\d+)(e[+-]?\d+)?([a-z]+|%)?/i);return c?(r+=c[0].length,a(Number(c[1]+(c[2]??"")),c[3])):i()}finally{n--}},d=()=>{let t=l();for(;;){o();let n=e[r];if("*"!==n&&"/"!==n)return t;r++;let a=l();if("/"===n){let e=a.terms.get("");if("number"!==a.kind||!e)return i();t=s(t,1/e)}else if("number"===a.kind)t=s(t,a.terms.get(""));else{if("number"!==t.kind)return i();t=s(a,t.terms.get(""))}}},u=()=>{let t=d();for(;;){o();let n=e[r];if("+"!==n&&"-"!==n)return t;r++;let a=d();if(t.kind!==a.kind)return i();for(let[e,r]of a.terms){let o=(t.terms.get(e)??0)+r*("-"===n?-1:1);Number.isFinite(o)||i(),t.terms.set(e,o)}}};try{let t=u();if(o(),")"!==e[r++]||e.slice(r).trim())return null;let n=[...t.terms].filter(([,e])=>0!==e);n.length||n.push([t.terms.keys().next().value??"",0]);let[i,a]=n[0];return{css:1===n.length?`${I(a)}${i}`:`calc(${n.map(([e,t],r)=>`${r?t<0?" - ":" + ":t<0?"-":""}${I(Math.abs(t))}${e}`).join("")})`,kind:t.kind,...1===n.length?{value:a,unit:i}:{}}}catch{return null}}function x(e,t){let r=e;for(let n of function(e){let t=[],r=/url\((?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^)'"])*\)|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\/\*[\s\S]*?\*\/|\bcalc\(/gi;for(let n;n=r.exec(e);){if(!/^calc\(/i.test(n[0]))continue;let i=1,o=r.lastIndex;for(;o<e.length&&i;)"("===e[o]?i++:")"===e[o]&&i--,o++;t.push({start:n.index,end:o,text:e.slice(n.index,o)}),r.lastIndex=o}return t}(e).reverse()){let e=$(n.text,t);if(!e)return null;r=r.slice(0,n.start)+e.css+r.slice(n.end)}return r}function E(e,t){let r=[],n=(e,t,n)=>{let i=k(e,{});i&&r.push({start:t,end:n,color:i})},i=(e,o=0,a=!1)=>{let s=0;for(;s<e.length;){let l=e[s];if('"'===l||"'"===l){let t=l;for(s++;s<e.length;s++)if("\\"===e[s])s++;else if(e[s]===t){s++;break}continue}if(e.startsWith("/*",s)){let t=e.indexOf("*/",s+2);s=t<0?e.length:t+2;continue}if("@"===l){let n=e.slice(s).match(/^@([^:@(),/]+):\s*([+-]?(?:\d+\.?\d*|\.\d+))(?![\w.])(?:\s*\/\s*[+-]?(?:\d+\.?\d*|\.\d+)%?(?![\w.%]))?(?!\s*\/)/),i=e.slice(s).match(/^@([\w-]+)(?![\w-]|\s*:)(?:\s*\/\s*([+-]?(?:\d+\.?\d*|\.\d+)%?)(?![\w.%]))?(?!\s*\/)/),l=a?e.slice(s).match(b):n??i;if(l){let e=g(t,l[0]),n=m(l[0]);n&&r.push({start:o+s,end:o+s+l[0].length,color:"color"===e?.kind?f(e):null,reference:n,...a?{math:!0}:{}}),s+=l[0].length}else s+=e.slice(s).match(/^@[^\s,()]*(?:\s*:\s*[^\s,()]*)?/)?.[0].length??1;continue}let d=e.slice(s).match(/^(?:#[\w-]+|[\w-]+)/)?.[0];if(!d){s++;continue}let u=s;if(s+=d.length,"("!==e[s]){a||n(d,o+u,o+s);continue}let c=++s,p=1,h="";for(;s<e.length&&p;){let t=e[s++];"\\"!==t?h?t===h&&(h=""):'"'===t||"'"===t?h=t:"("===t?p++:")"===t&&p--:s++}if(p)continue;let v=k(e.slice(u,s),{});v?r.push({start:o+u,end:o+s,color:v}):/^(?:(?:repeating-)?(?:linear|radial|conic)-gradient|drop-shadow|calc)$/i.test(d)&&i(e.slice(c,s-1),o+c,a||"calc"===d.toLowerCase())}};return i(e),r}function C(e,t){return E(e,t).flatMap(e=>e.color?[{...e,color:e.color}]:[])}function S(e,t){return E(e,t).flatMap(({reference:e,start:t,end:r,math:n})=>e?[{...e,start:t,end:r,...n?{math:!0}:{}}]:[])}function N(e,t){return C(e,t).map(({color:e})=>e)}function A(e,t){let r=S(e,t);return null!==x(e,t)&&r.length===(e.match(/@/g)?.length??0)&&r.every(({start:r,end:n})=>null!==g(t,e.slice(r,n)))}function R(e,t,r=!1){let n=x(e,t);if(null===n)return null;let i=n;for(let e of S(n,t).reverse()){let o=g(t,n.slice(e.start,e.end));if(!o)return null;i=i.slice(0,e.start)+f(o)+(r&&"layout"===o.kind&&!o.unit?"px":"")+i.slice(e.end)}return i}function j(e,t,r,n){if(void 0!==n){let i=S(e,r)[n];return!i||void 0!==i.opacity&&"color"!==t.kind||i.math&&"layout"!==t.kind?null:e.slice(0,i.start)+`@${t.name}${null===i.step?"":`: ${i.step}`}${void 0===i.opacity?"":` / ${i.opacity}`}`+e.slice(i.end)}let i=m(e);if(i||!e.trim())return void 0!==i?.opacity&&"color"!==t.kind?null:`@${t.name}${null===i?.step?"":`: ${i?.step??0}`}${void 0===i?.opacity?"":` / ${i.opacity}`}`;let o=C(e,r);if("color"===t.kind&&1===o.length){let{start:r,end:n}=o[0],i=m(e.slice(r,n));return`${e.slice(0,r)}@${t.name}${null===i?.step?"":`: ${i?.step??0}`}${void 0===i?.opacity?"":` / ${i.opacity}`}${e.slice(n)}`}return/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[a-z%]+)?$/i.test(e.trim())?`@${t.name}: 0`:null}var T=["page","body","heading","muted","card","button","input"],F=["color","backgroundColor","border","borderColor","borderWidth","borderRadius","boxShadow","padding","paddingInline","paddingBlock","gap","fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","opacity"];function L(e){var t;let r={};for(let n of e.usage??[]){if(!T.includes(n.target)||!F.includes(n.property))continue;let i=null;try{if("token"===n.source.kind){let t=e.tokens.find(e=>e.id===n.source.id);t&&(i=R(t.value,e.constraints,!["fontWeight","opacity"].includes(n.property)))}else if("dimension"===n.source.kind){let t=p(e.constraints,n.source.id,n.source.step??0);i=f(t),"layout"===t.kind&&!t.unit&&!["fontWeight","opacity"].includes(n.property)&&(i+="px")}}catch{continue}(i&&/^-?\d+(?:\.\d+)?$/.test(i)&&["fontSize","letterSpacing","padding","paddingInline","paddingBlock","gap","borderRadius","borderWidth"].includes(n.property)&&(i+="px"),!i||/[;{}]|\b(?:url|expression|var)\s*\(/i.test(i)||i.includes("\\")||[...i].some(e=>e.charCodeAt(0)<32)||typeof CSS<"u"&&CSS.supports&&!CSS.supports(n.property.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),i))||((r[t=n.target]??(r[t]={}))[n.property]=["fontWeight","opacity"].includes(n.property)&&Number.isFinite(Number(i))?Number(i):i)}return r}var U=["display","boxSizing","width","height","flexDirection","flexWrap","alignItems","justifyContent","alignSelf","flexGrow","flexShrink","gridTemplateColumns","rowGap","columnGap","gap","padding","paddingInline","paddingBlock","border","borderRadius","paddingTop","paddingRight","paddingBottom","paddingLeft","marginTop","marginRight","marginBottom","marginLeft","borderTop","borderRight","borderBottom","borderLeft","borderColor","borderWidth","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","color","backgroundColor","backgroundImage","boxShadow","opacity","fontFamily","fontSize","fontWeight","fontStyle","lineHeight","letterSpacing","textAlign","textTransform","textDecoration","whiteSpace","overflow","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","objectFit"],M=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;function z(e,t){return!!D(t)&&("flexGrow"===e||"flexShrink"===e?M.test(t)&&Number.isFinite(Number(t))&&Number(t)>=0:["display","boxSizing","flexDirection","flexWrap","alignItems","justifyContent","alignSelf","textAlign","whiteSpace","overflow","strokeLinecap","strokeLinejoin","objectFit"].includes(e)?!M.test(t):!!/^(none|normal|auto|transparent|currentcolor)$/i.test(t)||(/^(?:width|height|gridTemplateColumns)$/.test(e)?/^(?:min-content|max-content|fit-content|subgrid)$/.test(t):/^(?:padding|margin|border.*Radius|gap|rowGap|columnGap|letterSpacing|strokeWidth)/.test(e)?/^0(?:px|em|rem|%)?$/.test(t):/^border(Top|Right|Bottom|Left)$/.test(e)?/^(?:0px\b|.*\bnone\b)/.test(t):"opacity"===e?"1"===t:/^(?:backgroundColor|fill|stroke)$/.test(e)&&/^rgba\([^)]*,\s*0\)$/.test(t)))}function O(e,t){return{...e,tokens:[...e.tokens,...t.tokens??[]]}}function W(e){return/^(width|height|marginTop|marginRight|marginBottom|marginLeft|gridTemplateColumns)$/.test(e)}var B=e=>{throw new J(e)},D=e=>"string"==typeof e&&e.length>0&&e.length<=512&&!/[;{}\\]|\b(?:url|expression|var)\s*\(/i.test(e)&&![...e].some(e=>e.charCodeAt(0)<32),G=e=>"string"==typeof e&&/^[a-zA-Z0-9_-]{1,80}$/.test(e),q=new Set(["div","span","img","svg","path","circle","rect","line","polyline","polygon","ellipse","g"]),_=e=>"string"==typeof e&&e.length<=2e4&&/^(https?:\/\/|blob:https?:\/\/|data:image\/(png|jpeg|webp|gif);base64,)/i.test(e),Z=new Set(["viewBox","d","cx","cy","r","rx","ry","x","y","x1","x2","y1","y2","width","height","points","transform","fillRule","clipRule"]);function H(e){(!e||"object"!=typeof e||JSON.stringify(e).length>24e4)&&B("Invalid fragment capture.");let t=e,{evidence:r,draft:n}=t;(!r||!G(r.id)||![r.width,r.height].every(e=>Number.isFinite(e)&&e>0&&e<=1e4)||!Array.isArray(r.values)||r.values.length>180||!n||!Array.isArray(n.constraints)||n.constraints.length>32||!Array.isArray(n.tokens)||n.tokens.length>128)&&B("This component is too large to capture. Try a smaller element.");let i=new Set;for(let e of r.values)(!e||!G(e.id)||i.has(e.id)||!U.includes(e.property)||void 0!==e.local&&(!0!==e.local||!W(e.property))||!D(e.value))&&B("Unsupported captured style."),i.add(e.id);let o=0,a=new Set,s=(e,t)=>{(!e||!G(e.id)||a.has(e.id)||!q.has(e.tag)||++o>64||t>12||!Array.isArray(e.children)||e.children.length>128||!e.styles||"object"!=typeof e.styles)&&B("This component is too complex. Try a smaller element."),a.add(e.id);for(let[t,n]of Object.entries(e.styles))r.values.some(e=>e.id===n&&e.property===t)||B("Invalid captured style reference.");for(let[t,r]of Object.entries(e.attributes??{}))"img"===e.tag&&"src"===t&&_(r)||(!Z.has(t)||"string"!=typeof r||r.length>12e3||!/^[\d\w\s.,+()-]*$/.test(r))&&B("Unsupported vector geometry.");for(let r of e.children)"string"==typeof r?r.length>2e3&&B("Too much captured text."):s(r,t+1)};return s(r.root,0),t}function K(e,t,r){try{let n,i=["fontWeight","opacity","flexGrow","flexShrink","strokeWidth"].includes(r);if("token"===t.kind){let r=e.tokens.find(e=>e.id===t.id);n=r?R(r.value,e.constraints,!i):null}else{let r=p(e.constraints,t.id,t.step??0);n=f(r),"layout"===r.kind&&!r.unit&&!i&&(n+="px")}return D(n)?n:null}catch{return null}}function V(e,t){let r=["div","span","img"].includes(t.tag)?{all:"initial"}:{};for(let[e,n]of Object.entries(t.localStyles??{}))U.includes(e)&&(z(e,n)||W(e)&&D(n))&&(r[e]=["flexGrow","flexShrink","opacity","strokeWidth"].includes(e)&&Number.isFinite(Number(n))?Number(n):n);for(let[n,i]of Object.entries(t.styles)){if(!U.includes(n))continue;let t=K(e,i,n);null!==t&&(r[n]=["fontWeight","opacity","flexGrow","flexShrink","strokeWidth"].includes(n)&&Number.isFinite(Number(t))?Number(t):t)}return r}var J=class extends Error{};function P(){let e=t();return{...e,tokens:[],constraints:e.constraints.map(e=>({...e,value:"",parentId:null}))}}function X(e,t){t=O(t,e);let r=new Map,n=e=>{let r=t.constraints.find(t=>t.id===e);return r?r.parentId?`@${t.constraints.find(e=>e.id===r.parentId)?.name??r.parentId}${"font"===r.kind?"":"color"===r.kind?` · hue ${r.derivative}°`:` × ${r.derivative}`}`:r.value:"Missing dimension"},i=e=>{let o=e.children.filter(e=>"string"==typeof e).join(" ").trim();for(let[i,a]of Object.entries(e.styles)){let s=`${a.kind}:${a.id}:${a.step??0}`,l=r.get(s);if(!l){let e="token"===a.kind?t.tokens.find(e=>e.id===a.id):void 0,i="dimension"===a.kind?t.constraints.find(e=>e.id===a.id):void 0,o=[],d=new Set("dimension"===a.kind?[a.id]:[]),u=e=>{if(d.has(e))return;d.add(e);let r=t.constraints.find(t=>t.id===e);if(!r)return;let i="Unresolved";try{i=f(p(t.constraints,e))}catch{}o.push({id:e,name:r.name,expression:n(e),value:i}),r.parentId&&u(r.parentId)};e&&S(e.value,t.constraints).forEach(e=>{let r=t.constraints.find(t=>t.name===e.name);r&&u(r.id)}),i?.parentId&&u(i.parentId),l={key:s,source:a,name:e?.name??i?.name??a.id,expression:e?.value??n(a.id),derived:o.length>0,dependencies:o,values:[],targets:[]},r.set(s,l)}let d=K(t,a,i)??"Unresolved";l.values.includes(d)||l.values.push(d),l.targets.push({nodeId:e.id,label:o.slice(0,64)||`${e.tag} · ${e.id}`,property:i})}e.children.forEach(e=>{"string"!=typeof e&&i(e)})};return i(e.root),[...r.values()]}function Q(e){let t=new Map(e.constraints.map(e=>[e.id,[]]));for(let r of e.constraints)r.parentId&&t.get(r.parentId)?.push({kind:"dimension",id:r.id});function r(r,n){return Object.fromEntries(r.map(r=>{let i=S(r.value,e.constraints).map((i,o)=>{let a=e.constraints.find(e=>e.name.toLowerCase()===i.name.toLowerCase()),s=i.step??0;return a&&t.get(a.id)?.push({kind:"token",id:r.id,...n?{fragmentId:n}:{},referenceIndex:o,step:s,...void 0!==i.opacity?{opacity:i.opacity}:{}}),{dimensionId:a?.id??null,expression:r.value.slice(i.start,i.end),step:s}});return[r.id,{...r,references:i,bindings:o("token",r.id,n),resolved:R(r.value,e.constraints)}]}))}let n=e.usage??[],i=(e.fragments??[]).map(t=>({fragment:t,uses:X(t,e)}));function o(e,t,r){return{usage:r?[]:n.filter(r=>r.source.kind===e&&r.source.id===t),components:i.flatMap(({fragment:n,uses:i})=>r&&n.id!==r?[]:i.filter(i=>i.source.kind===e&&i.source.id===t&&("token"!==e||r||!n.tokens?.some(e=>e.id===t))).map(e=>({fragmentId:n.id,step:e.source.step??0,targets:e.targets})))}}let a=r(e.tokens),s=Object.fromEntries(i.map(({fragment:e,uses:t})=>[e.id,{name:e.name,tokens:r(e.tokens??[],e.id),uses:t}]));return{dimensions:Object.fromEntries(e.constraints.map(r=>{let n=Object.fromEntries(("font"===r.kind?[0]:[-2,-1,0,1,2]).map(t=>{try{return[t,f(p(e.constraints,r.id,t))]}catch{return[t,null]}})),i=r.parentId?"font"===r.kind?"inherit":"color"===r.kind?"rotate-hue":"multiply":"literal";return[r.id,{...r,derivation:i,resolvedBase:n[0],steps:n,dependents:t.get(r.id),bindings:o("dimension",r.id)}]})),tokens:a,usage:e.usage??[],resolvedUsage:L(e),components:s,featuredComponentId:e.featuredComponentId??null}}var Y=(e,t=512)=>"string"==typeof e&&e.length<=t&&![...e].some(e=>e.charCodeAt(0)<32)&&!/[;{}]|\b(?:url|expression)\s*\(/i.test(e);function ee(e,t){if(!t||"object"!=typeof t||Array.isArray(t)||Object.keys(t).some(e=>!["name","constraints","tokens","usage","featuredComponentId"].includes(e)))throw Error("Invalid proposal patch.");let r=structuredClone(e);if(void 0!==t.featuredComponentId){if(null!==t.featuredComponentId&&!r.fragments?.some(e=>e.id===t.featuredComponentId))throw Error("The featured component must belong to this Taste.");r.featuredComponentId=t.featuredComponentId}if(void 0!==t.name){if("string"!=typeof t.name||t.name.length>80)throw Error("Invalid name.");r.name=t.name}if(void 0!==t.constraints){if(!Array.isArray(t.constraints)||t.constraints.length>32)throw Error("Invalid dimensions.");let e=new Set;for(let n of t.constraints){if(!n||"object"!=typeof n||Object.keys(n).some(e=>!["id","value","parentId","derivative","scale"].includes(e)))throw Error("Invalid dimension patch.");let t=r.constraints.find(e=>e.id===n.id);if(!t||e.has(n.id))throw Error("Unknown or duplicate dimension ID.");if(e.add(n.id),Object.assign(t,n),!Y(t.value)||!Number.isFinite(t.derivative)||!Number.isFinite(t.scale)||t.scale<0||"increment"===t.scaleMode&&t.scale<=0||"color"===t.kind&&t.scale>1||"font"===t.kind&&(1!==t.scale||1!==t.derivative)||"layout"===t.kind&&t.derivative<0||null!==t.parentId&&!r.constraints.some(e=>e.id===t.parentId&&e.kind===t.kind))throw Error(`Invalid ${t.id} dimension.`)}for(let e of r.constraints)(e.value||e.parentId)&&p(r.constraints,e.id)}if(void 0!==t.tokens){if(!Array.isArray(t.tokens)||t.tokens.length>128)throw Error("Invalid tokens.");let e=new Set,n=new Set;for(let r of t.tokens){if(!r||"string"!=typeof r.id||!/^[a-zA-Z0-9_-]{1,80}$/.test(r.id)||"string"!=typeof r.name||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.name)||!Y(r.value)||e.has(r.id)||n.has(r.name))throw Error("Invalid or duplicate token.");e.add(r.id),n.add(r.name)}r.tokens=structuredClone(t.tokens)}void 0!==t.usage&&(r.usage=structuredClone(t.usage));for(let e of r.tokens)if(!A(e.value,r.constraints))throw Error(`Invalid reference or calc expression in ${e.name}.`);if(!Array.isArray(r.usage??[])||(r.usage?.length??0)>128)throw Error("Invalid usage mappings.");for(let e of r.usage??[])if(!e||Object.keys(e).some(e=>!["target","property","source"].includes(e))||!T.includes(e.target)||!F.includes(e.property)||!e.source||Object.keys(e.source).some(e=>!["kind","id","step"].includes(e))||!["token","dimension"].includes(e.source.kind)||!("token"===e.source.kind?r.tokens:r.constraints).some(t=>t.id===e.source.id)||void 0!==e.source.step&&(!Number.isInteger(e.source.step)||Math.abs(e.source.step)>100))throw Error("Usage must reference an existing token or dimension.");return r}function te(e,r=!0,n=!0){let i=t(),o={past:[],future:[]},a={current:{past:[],future:[]}},s={available:r,revision:crypto.randomUUID(),runId:"",openRequest:"",open:!1,mode:"empty",state:e?"complete":"idle",message:"",draft:e??null},l=new Set,d=null,u=new Set,c=e=>{d={id:crypto.randomUUID(),target:e,expiresAt:Date.now()+2e3},u.forEach(e=>e())},m=()=>{d=null,u.forEach(e=>e())},h=e=>{s={...s,...e,revision:crypto.randomUUID()},l.forEach(e=>e())},g={setCreationAllowed(e){n=e},history:a,getLookSnapshot:()=>d,subscribeLook:e=>(u.add(e),()=>{u.delete(e)}),setAvailable(e){s.available!==e&&h({available:e})},getSnapshot:()=>s,subscribe:e=>(l.add(e),()=>{l.delete(e)}),create(e="template",r=!1){if(!n)throw Error("An active subscription is required to create a Taste.");m(),"template"===e&&!r&&(i=t()),"template"===e?(r||(o.past=[],o.future=[]),a.current=o):a.current={past:[],future:[]},h({open:!0,openRequest:crypto.randomUUID(),runId:crypto.randomUUID(),mode:e,state:"extract"===e?"running":"complete",message:"",draft:"template"===e?i:P()})},edit(e){"running"!==s.state&&("template"===s.mode&&(i=e),h({draft:e}))},addFragment(e,t){if(s.runId!==e||!s.open||"running"===s.state||!s.draft)throw Error("This proposal has changed. Capture the component again.");let r=s.draft;if((r.fragments?.length??0)>=16)throw Error("A proposal can contain up to 16 components.");if(r.fragments?.some(e=>e.id===t.fragment.id))throw Error("This component was already captured.");if(t.tokens.some(e=>r.tokens.some(t=>t.id===e.id||t.name===e.name)))throw Error("A component token conflicts with a shared token. Retry capture.");let n=ee({...r,usage:[]},{tokens:t.tokens}),i=e=>{for(let t of Object.values(e.styles))if(!("token"===t.kind?[...r.tokens,...n.tokens]:n.constraints).some(e=>e.id===t.id))throw Error("A referenced Taste value was removed. Retry capture.");e.children.forEach(e=>{"string"!=typeof e&&i(e)})};i(t.fragment.root);let o={...r,fragments:[...r.fragments??[],{...t.fragment,tokens:t.tokens}]};return a.current.past.push(r),a.current.past.length>100&&a.current.past.shift(),a.current.future=[],g.edit(o),o},stream(e,t){s.runId===e&&"running"===s.state&&h(t)},close(){m(),h({open:!1,..."running"===s.state?{state:"error",message:"Extraction stopped. Retry or continue editing the partial draft."}:{}})},command(e){let t=(e,t={})=>({status:e,...s,...t,saved:!1,applied:!1});if(void 0!==e.target&&"inspect"!==e.action)return t("invalid",{error:"target is only supported for inspection."});if("inspect"===e.action){let r=e.target;if(void 0!==r){let{draft:t,...n}=s,i=(e,t={})=>({status:e,...n,saved:!1,applied:!1,...t});if(!r||!["dimension","token"].includes(r.kind)||"string"!=typeof r.id||!r.id||r.id.length>200)return i("invalid");let o=("dimension"===r.kind?t?.constraints:t?.tokens)?.find(e=>e.id===r.id);if(!o||!t)return i("not_found",{target:r});let a,l=null;try{l="dimension"===r.kind?f(p(t.constraints,r.id)):R(o.value,t.constraints)}catch(e){a=e instanceof Error?e.message:"Not resolved yet"}return c({kind:r.kind,id:r.id}),i("ok",{target:r,row:o,resolved:l,...!0===e.includeRelationships?{relationships:Q(t)["dimension"===r.kind?"dimensions":"tokens"][r.id]}:{},...a?{resolutionError:a}:{}})}return s.draft&&c(null),t("ok")}if(!s.available)return t("unavailable",{error:"The host Taste panel is not available in this browser."});if(!["create","modify"].includes(e.action))return t("invalid",{error:"Unknown proposal action."});if(!e.expectedRevision||e.expectedRevision!==s.revision)return t("conflict");if("running"===s.state)return t("busy");try{if("create"===e.action){let t=e.mode??"template";if(!["template","empty","extract"].includes(t)||e.patch)throw Error("Create accepts a mode; modify the returned draft separately.");g.create(t)}else{if(!s.draft)return t("not_found");let r=ee(s.draft,e.patch);a.current.past=[...a.current.past.slice(-99),s.draft],a.current.future=[],"template"===s.mode&&(i=r),h({draft:r,open:!0,openRequest:crypto.randomUUID()})}return t("ok")}catch(e){return t("invalid",{error:e instanceof Error?e.message:"Invalid patch."})}}};return g}var re=te(null,!1,!1);e.connect(re);export{K as A,V as B,P as C,X as D,te as E,re as F,t as a,n as b,u as c,c as d,p as e,f,m as g,h,g as i,v as j,y as k,k as l,$ as m,x as n,C as o,S as p,N as q,R as r,j as s,L as t,U as u,O as v,W as w,D as x,_ as y,H as z};
|