@pickaxeproject/react 5.6.0 → 5.6.1-beta.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/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Submit.js +1 -1
- package/dist/cjs/components/Pickaxe/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/common/AccessGroupCardPreview.js +1 -0
- package/dist/cjs/components/Pickaxe/common/PickaxeAvatar.js +1 -0
- package/dist/cjs/components/Pickaxe/common/PickaxeCommon.js +1 -0
- package/dist/cjs/components/Pickaxe/common/PickaxeCurrency.js +1 -0
- package/dist/cjs/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/cjs/components/Pickaxe/index.js +1 -1
- package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
- package/dist/cjs/src/components/Pickaxe/Provider.d.ts +3 -1
- package/dist/cjs/src/components/Pickaxe/ResponseProvider.d.ts +6 -3
- package/dist/cjs/src/components/Pickaxe/common/AccessGroupCardPreview.d.ts +9 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeAvatar.d.ts +16 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeCommon.d.ts +2 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeCurrency.d.ts +7 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeUpgradeCard.d.ts +1 -1
- package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
- package/dist/cjs/src/types/response.d.ts +8 -0
- package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Submit.js +1 -1
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/common/AccessGroupCardPreview.js +1 -0
- package/dist/esm/components/Pickaxe/common/PickaxeAvatar.js +1 -0
- package/dist/esm/components/Pickaxe/common/PickaxeCommon.js +1 -0
- package/dist/esm/components/Pickaxe/common/PickaxeCurrency.js +1 -0
- package/dist/esm/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/esm/components/Pickaxe/index.js +1 -1
- package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
- package/dist/esm/src/components/Pickaxe/Provider.d.ts +3 -1
- package/dist/esm/src/components/Pickaxe/ResponseProvider.d.ts +6 -3
- package/dist/esm/src/components/Pickaxe/common/AccessGroupCardPreview.d.ts +9 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeAvatar.d.ts +16 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeCommon.d.ts +2 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeCurrency.d.ts +7 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeUpgradeCard.d.ts +1 -1
- package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
- package/dist/esm/src/types/response.d.ts +8 -0
- package/package.json +205 -202
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../Addons/Auth/hooks/useAuthContext.js"),t=require("../../Addons/Auth/hooks/useAuth.js"),l=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/pickaxe/useDimensionContext.js"),r=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),c=require("../../../../hooks/pickaxe/useConversation.js"),d=require("../../Addons/Artifact/hooks/useArtifactContext.js"),u=require("framer-motion"),x=require("../../../Icons/lock.svg.js"),m=require("../../../Core/ErrorAlert.js"),f=require("../../common/PickaxeHead.js"),j=require("../../common/PickaxeEmbedHead.js"),h=require("../../common/PickaxeUpgradeCard.js"),g=require("../../common/PickaxeSkeleton.js"),p=require("../../common/PickaxeHistoryButton.js"),b=require("../../Addons/Scroll/ScrollLockView.js"),v=require("../../Addons/Artifact/Renderer/index.js"),y=require("./Message.js"),k=require("./CustomMessage.js"),w=require("../../Addons/IceBreaker/index.js"),N=require("../../common/PickaxeBranding.js"),C=require("../../../../common/cn.js");exports.default=({additionalScrollHeight:O,smitheryAuthData:q,isForceHideInfo:S,isInputFocused:A,onSubmit:P,resubmitPrompt:I})=>{var H,L,R,M,D;const{sessionId:E,deploymentType:F,pickaxe:B,translations:T,misc:z,isNewChat:W,isRtl:_,isEmbed:$,isEmailLogin:U,isShowIceBreaker:V,setSessionId:G,setLastSessionId:J}=i.usePickaxeContext(),{emailInput:K,isLoggedOut:Q,isSending:X,isResendDisabled:Y,isSent:Z}=a.useAuthContext(),{onSend:ee}=t.useAuth(),{scrollContainerRef:se}=r.useScrollContext(),{messages:ie,limitData:ae,error:te}=l.useResponseContext(),{height:le,width:ne}=n.useDimensionContext(),{currentArtifact:re,chatPopupType:oe,currentPopupType:ce}=d.useArtifactContext(),de=c.useConversation(),ue=o.useStyleFontSize(),xe=s.useMemo((()=>(null==B?void 0:B.icebreakers)?B.icebreakers.slice(0,3):[]),[null==B?void 0:B.icebreakers]),me=s.useMemo((()=>{const e=!!de.data&&de.data.messages.length>1;return!S&&de.isSuccess&&W&&!e}),[S,de.isSuccess,W,de.data]),fe=s.useMemo((()=>!(null==B?void 0:B.chatflag)&&(null==B?void 0:B.enablechatresponses)&&ie.length>0),[B,ie]),je=s.useMemo((()=>!!de.data&&de.data.messages.some((e=>"intromessage"===e.area))),[de.data]),he="chat-input"===F&&U&&Q&&Z,ge=V&&!A&&!je&&me&&ne>767,pe=V&&!A&&(je||ne<=767),be=()=>{J(E),G("")};return s.useEffect((()=>{se.current&&requestAnimationFrame((()=>{se.current&&(se.current.scrollTop=se.current.scrollHeight)}))}),[O,se]),e.jsxs("div",Object.assign({ref:se,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[e.jsx(u.AnimatePresence,{children:!!re&&"inline"===ce&&e.jsx(u.motion.div,Object.assign({className:C.default("absolute top-0 z-20 w-full px-4 py-2",oe),style:{height:`calc(${le-O}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:e.jsx(v.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:re.id,version:re.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[me&&$&&e.jsx("div",Object.assign({className:C.default("absolute right-4 top-3 flex items-center gap-2","popup"===F&&"right-12")},{children:e.jsx(p.default,{tip:(null==T?void 0:T["chat-history"])||"Chat History",onClick:be})})),e.jsx(f.default,Object.assign({className:C.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",me&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!he&&{onIconClick:be})),$&&!de.isLoading&&e.jsx(j.default,Object.assign({className:C.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!me&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==T?void 0:T["chat-history"])||"Chat History"},!he&&{onIconClick:be,onHistoryClick:be})),e.jsxs("div",Object.assign({className:C.default("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",$&&!de.isLoading&&!me&&"mt-0")},{children:[ge&&e.jsx("div",Object.assign({className:C.default("grid grid-cols-3 gap-4",2===xe.length&&"grid-cols-2",1===xe.length&&"grid-cols-1")},{children:e.jsx(w.default,{type:"center",data:xe,onSend:P})})),he?e.jsx("div",Object.assign({className:"flex flex-col w-full"},{children:e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[e.jsx(k.default,Object.assign({chatRole:"user"},{children:e.jsxs("div",Object.assign({className:"flex items-center gap-x-3"},{children:[e.jsx(x.default,{className:"h-6 w-6 shrink-0"}),e.jsx("p",Object.assign({className:"font-semilight"},{children:K}))]}))})),e.jsx(k.default,Object.assign({chatRole:"assistant"},{children:e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(R=null==T?void 0:T["we-sent-your-an-activation-link"])&&void 0!==R?R:"We sent you an activation link. Please be sure to check your spam folder too."} `,e.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{Y||X||ee(!0)}},{children:X?null!==(M=null==T?void 0:T.resending)&&void 0!==M?M:"Resending...":null!==(D=null==T?void 0:T.resend)&&void 0!==D?D:"Resend"}))]}))}))]}))})):e.jsx(e.Fragment,{children:de.isLoading&&!(null==B?void 0:B.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[W&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(g.default,{className:"w-[72px] h-[72px]"}),e.jsx(g.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(g.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(g.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(g.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):de.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:C.default(ue.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):de.data||fe?e.jsxs("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(L=null===(H=de.data)||void 0===H?void 0:H.messages)&&void 0!==L?L:[]).map(((s,i)=>e.jsx(y.default,{index:i,message:s},i))),ie.map(((s,i)=>{var a,t;return e.jsx(y.default,{smitheryData:q,resubmitPrompt:I,index:(null!==(t=null===(a=de.data)||void 0===a?void 0:a.messages.length)&&void 0!==t?t:0)+i,message:s,isLastMessage:i===ie.length-1},i)})),ae?e.jsx("div",Object.assign({className:"flex max-w-[
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../Addons/Auth/hooks/useAuthContext.js"),t=require("../../Addons/Auth/hooks/useAuth.js"),l=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/pickaxe/useDimensionContext.js"),r=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),c=require("../../../../hooks/pickaxe/useConversation.js"),d=require("../../Addons/Artifact/hooks/useArtifactContext.js"),u=require("framer-motion"),x=require("../../../Icons/lock.svg.js"),m=require("../../../Core/ErrorAlert.js"),f=require("../../common/PickaxeHead.js"),j=require("../../common/PickaxeEmbedHead.js"),h=require("../../common/PickaxeUpgradeCard.js"),g=require("../../common/PickaxeSkeleton.js"),p=require("../../common/PickaxeHistoryButton.js"),b=require("../../Addons/Scroll/ScrollLockView.js"),v=require("../../Addons/Artifact/Renderer/index.js"),y=require("./Message.js"),k=require("./CustomMessage.js"),w=require("../../Addons/IceBreaker/index.js"),N=require("../../common/PickaxeBranding.js"),C=require("../../../../common/cn.js");exports.default=({additionalScrollHeight:O,smitheryAuthData:q,isForceHideInfo:S,isInputFocused:A,onSubmit:P,resubmitPrompt:I})=>{var H,L,R,M,D;const{sessionId:E,deploymentType:F,pickaxe:B,translations:T,misc:z,isNewChat:W,isRtl:_,isEmbed:$,isEmailLogin:U,isShowIceBreaker:V,setSessionId:G,setLastSessionId:J}=i.usePickaxeContext(),{emailInput:K,isLoggedOut:Q,isSending:X,isResendDisabled:Y,isSent:Z}=a.useAuthContext(),{onSend:ee}=t.useAuth(),{scrollContainerRef:se}=r.useScrollContext(),{messages:ie,limitData:ae,error:te}=l.useResponseContext(),{height:le,width:ne}=n.useDimensionContext(),{currentArtifact:re,chatPopupType:oe,currentPopupType:ce}=d.useArtifactContext(),de=c.useConversation(),ue=o.useStyleFontSize(),xe=s.useMemo((()=>(null==B?void 0:B.icebreakers)?B.icebreakers.slice(0,3):[]),[null==B?void 0:B.icebreakers]),me=s.useMemo((()=>{const e=!!de.data&&de.data.messages.length>1;return!S&&de.isSuccess&&W&&!e}),[S,de.isSuccess,W,de.data]),fe=s.useMemo((()=>!(null==B?void 0:B.chatflag)&&(null==B?void 0:B.enablechatresponses)&&ie.length>0),[B,ie]),je=s.useMemo((()=>!!de.data&&de.data.messages.some((e=>"intromessage"===e.area))),[de.data]),he="chat-input"===F&&U&&Q&&Z,ge=V&&!A&&!je&&me&&ne>767,pe=V&&!A&&(je||ne<=767),be=()=>{J(E),G("")};return s.useEffect((()=>{se.current&&requestAnimationFrame((()=>{se.current&&(se.current.scrollTop=se.current.scrollHeight)}))}),[O,se]),e.jsxs("div",Object.assign({ref:se,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[e.jsx(u.AnimatePresence,{children:!!re&&"inline"===ce&&e.jsx(u.motion.div,Object.assign({className:C.default("absolute top-0 z-20 w-full px-4 py-2",oe),style:{height:`calc(${le-O}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:e.jsx(v.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:re.id,version:re.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[me&&$&&e.jsx("div",Object.assign({className:C.default("absolute right-4 top-3 flex items-center gap-2","popup"===F&&"right-12")},{children:e.jsx(p.default,{tip:(null==T?void 0:T["chat-history"])||"Chat History",onClick:be})})),e.jsx(f.default,Object.assign({className:C.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",me&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!he&&{onIconClick:be})),$&&!de.isLoading&&e.jsx(j.default,Object.assign({className:C.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!me&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==T?void 0:T["chat-history"])||"Chat History"},!he&&{onIconClick:be,onHistoryClick:be})),e.jsxs("div",Object.assign({className:C.default("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",$&&!de.isLoading&&!me&&"mt-0")},{children:[ge&&e.jsx("div",Object.assign({className:C.default("grid grid-cols-3 gap-4",2===xe.length&&"grid-cols-2",1===xe.length&&"grid-cols-1")},{children:e.jsx(w.default,{type:"center",data:xe,onSend:P})})),he?e.jsx("div",Object.assign({className:"flex flex-col w-full"},{children:e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[e.jsx(k.default,Object.assign({chatRole:"user"},{children:e.jsxs("div",Object.assign({className:"flex items-center gap-x-3"},{children:[e.jsx(x.default,{className:"h-6 w-6 shrink-0"}),e.jsx("p",Object.assign({className:"font-semilight"},{children:K}))]}))})),e.jsx(k.default,Object.assign({chatRole:"assistant"},{children:e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(R=null==T?void 0:T["we-sent-your-an-activation-link"])&&void 0!==R?R:"We sent you an activation link. Please be sure to check your spam folder too."} `,e.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{Y||X||ee(!0)}},{children:X?null!==(M=null==T?void 0:T.resending)&&void 0!==M?M:"Resending...":null!==(D=null==T?void 0:T.resend)&&void 0!==D?D:"Resend"}))]}))}))]}))})):e.jsx(e.Fragment,{children:de.isLoading&&!(null==B?void 0:B.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[W&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(g.default,{className:"w-[72px] h-[72px]"}),e.jsx(g.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(g.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(g.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(g.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):de.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:C.default(ue.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):de.data||fe?e.jsxs("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(L=null===(H=de.data)||void 0===H?void 0:H.messages)&&void 0!==L?L:[]).map(((s,i)=>e.jsx(y.default,{index:i,message:s},i))),ie.map(((s,i)=>{var a,t;return e.jsx(y.default,{smitheryData:q,resubmitPrompt:I,index:(null!==(t=null===(a=de.data)||void 0===a?void 0:a.messages.length)&&void 0!==t?t:0)+i,message:s,isLastMessage:i===ie.length-1},i)})),ae?e.jsx("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:e.jsx(h.default,{})})):te?e.jsx("div",Object.assign({className:C.default("flex items-center gap-x-3",_?"justify-end":"justify-start")},{children:e.jsx(m.default,{error:te})})):null]})),e.jsxs("div",Object.assign({className:C.default("flex flex-col",!z.isWhiteLabel||pe&&"mt-4")},{children:[!z.isWhiteLabel&&e.jsx(N.default,{containerClassName:C.default("justify-end",pe&&"mb-2")}),pe&&e.jsx("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:e.jsx(w.default,{type:"right",data:xe,onSend:P})})),e.jsx(b.default,{})]}))]})):null})]}))]}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react");require("../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),r=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),c=require("../../../hooks/pickaxe/useDimensionContext.js"),u=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),h=require("../../../hooks/core/useHover.js"),m=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),y=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),w=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),S=require("../../Core/ErrorAlert.js"),k=require("../../../common/error.js"),C=require("../../../common/cn.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var I=N(n);const _=s.forwardRef((({resubmitPrompt:N,onFocus:_,onBlur:E,onInputHeightChange:A,initSmitheryAuthData:q},R)=>{var T,P,D;const{origin:L,pickaxeId:H,sessionId:M,sender:F,senderType:$,deploymentId:W,deploymentType:B,pickaxe:J,styles:U,colors:V,locale:K,forceMobile:X,isNewChat:z,isRtl:G,isEmailLogin:Q,isShowFeedbackMessage:Y,setIsNewChat:Z,setIsShowIceBreaker:ee,onGenerateComplete:te}=r.usePickaxeContext(),{token:se,isLoggedOut:ne,isSent:re}=u.useAuthContext(),{messages:ie,limits:oe,isGenerating:ae,setMessages:le,setStatus:ce,setLimitData:ue,setError:de}=i.useResponseContext(),{documents:fe,isUploading:pe,documentError:he,onFileUpload:me,setDocuments:ge,setDocumentError:ve}=d.useDocument(),{scrollStartSession:ye,scrollEndSession:be,scrollToBottom:xe}=f.useScroll({auto:!0}),{artifacts:je,currentPopupType:we,setArtifacts:Oe,setCurrentArtifact:Se}=p.useArtifactContext(),{height:ke}=c.useDimensionContext(),Ce=l.useConversation(),[Ne,Ie]=s.useState(""),[_e,Ee]=s.useState(!1),[Ae,qe]=s.useState(!1),Re=s.useRef(null),Te=s.useRef(""),Pe=s.useRef(null),De=s.useRef(null),Le=s.useRef(null),He=s.useRef(null),Me=s.useRef(null),Fe=Math.max(.4*ke,100),{transcript:$e,listening:We,resetTranscript:Be,browserSupportsSpeechRecognition:Je}=n.useSpeechRecognition(),[Ue]=m.useMediaQuery("(max-width: 480px)"),Ve=h.useHover(),{isHover:Ke}=Ve,Xe=e.__rest(Ve,["isHover"]),ze=h.useHover(),{isHover:Ge}=ze,Qe=e.__rest(ze,["isHover"]),Ye=h.useHover(),{isHover:Ze}=Ye,et=e.__rest(Ye,["isHover"]),tt=a.useStyleFontSize(),st=o.useStyleInput(),nt="undefined"!=typeof window?window.location.hostname:"",rt="undefined"!=typeof window?window.location.href:"",it="undefined"!=typeof window&&window.self!==window.top,ot=nt.includes("pickaxe.co")&&!rt.includes("https://studio.pickaxe.co/_embed")&&!it,at=null===(T=null==J?void 0:J.documentuploadtype)||void 0===T?void 0:T.startsWith("enduserupload"),lt=Je&&(null==J?void 0:J.enablevoicetotext),ct="chat-input"===B&&z&&!re,ut="chat-input"===B&&Q&&ne&&re,dt=null!==(P=null==J?void 0:J.placeholdertext)&&void 0!==P?P:G?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",ft=_e||Ae,pt=s.useMemo((()=>{var e,t,s;return!!z&&(!!J&&(!Ce.isLoading&&(!((null!==(t=null===(e=Ce.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=J.icebreakers)||void 0===s?void 0:s.length)&&(!Y&&!ct)))))}),[J,z,Y,ct,Ce.data,Ce.isLoading]),ht=s.useMemo((()=>{if(ae||pe)return!1;const e=fe.length>0&&fe.every((e=>"finished"===e.status));return!(!Ne.trim()&&!e)&&fe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ae,pe,Ne,fe]);s.useImperativeHandle(R,(()=>({onSubmit:mt}))),s.useEffect((()=>{ee(pt)}),[pt]),s.useEffect((()=>{var e;if(N){const t=Array.from(ie),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;mt(s,!0)}}),[N]),s.useEffect((()=>{if(!He.current||!A)return;const e=new ResizeObserver((e=>{for(const t of e)A(t.contentRect.height)}));return e.observe(He.current),()=>{e.disconnect()}}),[A]),s.useEffect((()=>{if(!We)return;const e=Te.current?`${Te.current} `:"";Ie(`${e}${$e}`)}),[$e,We]),s.useEffect((()=>{if(!De.current)return;(()=>{if(!De.current)return;let e=De.current.scrollHeight>52;Ne.includes("\n")||fe.length?e=!0:Ne.trim()||(e=!1),Ee(e)})()}),[Ne,fe]),s.useEffect((()=>{const e=De.current,t=Le.current;if(!e||!t||_e||Ne.includes("\n"))return void qe(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,r=document.createElement("span");Object.assign(r.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),r.textContent=Ne||dt,document.body.appendChild(r);const i=r.offsetWidth;r.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;qe(i>l)}),[Ne,_e,dt]);const mt=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,r;try{if(ae||pe)return;const i=fe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),o=i.map((e=>e.documentId)).filter(Boolean),a=i.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=o.length>0,c=null!=t?t:Ne;if(!c&&!l)return;de(""),ve(""),ue(null),Ie(""),Z(!1),ce("fetching"),ye(),xe();const u=null!==(n=null===(e=null==J?void 0:J.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&o.length>0,d=[...s?Array.from(ie.slice(0,ie.length-1)):Array.from(ie),...s?[]:[{id:ie.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:u?o:[]}],{id:ie.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];le(d),xe(),u&&ge([]);const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:L,pickaxeId:H,sessionId:M,senderType:$,value:c},u&&{documentIds:o}),F&&{sender:F}),se&&{studioSessionToken:se}),W&&{deploymentId:W}),a.length>0&&{uploadedModelImages:a}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),ot&&{credentials:"include"})),p=yield f.json();if(!p.success)throw new Error(p.error||"Failed to start generation");const h=p.submissionId;ce("streaming"),Me.current=new AbortController;const m=d.length-1,g=[];let y=[...null!=je?je:[]],b=0,x=!1,j="";for(;!x;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${h}?index=${b}`,{signal:null===(r=Me.current)||void 0===r?void 0:r.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Pe.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&b++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return de(t),void(x=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&q){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw x=!0,q({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw x=!0,q({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)j="",g.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("text-end"===n.type)j="";else if("reasoning-start"===n.type)j="",g.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("reasoning-end"===n.type)j="";else if(n.type.startsWith("data-")){const e=n;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}le([...d.slice(0,m),Object.assign(Object.assign({},d[d.length-1]),{id:ie.length+1,role:"assistant",parts:g})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);y=y.filter((e=>!(e.id===t.id&&e.version===t.version))),y.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Oe([...y]),we.startsWith("inline")||Se({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);y=y.filter((e=>!(e.id===t.id&&e.version===t.version))),y.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Oe(y),we.startsWith("inline")||Se({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);y=y.filter((e=>!(e.id===t.id&&e.version===t.version))),y.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Oe(y),we.startsWith("inline")||Se({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");y=y.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Oe(y)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Oe(y.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);de(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(x=!0)}else x=!0}});for(;;){const{value:e,done:r}=yield t.read();if(r)break;n.feed(s.decode(e))}x||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(x=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==te||te(M)}catch(e){let t=k.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(oe).find((([e])=>t.includes(e)));s?ue(s[1]):de(t)}finally{xe(),ce("idle"),be(),Pe.current=null}}));return ut?null:t.jsx("div",Object.assign({className:C.default("flex w-full flex-shrink-0 flex-col items-center",!ct&&"px-4 pb-8"),dir:G?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:He,className:C.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===U.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},st),{maxHeight:`${Fe}px`,overflowY:"auto"})},{children:[We&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(D=V.accent)&&void 0!==D?D:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:V.text+"90"}},{children:"Listening..."}))]})),!ae&&fe.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:ae}),t.jsx(O.default,Object.assign({ref:De,className:C.default(tt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Ne.trim()&&!Ne.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",G?"text-right":"text-left",ft&&"mb-12",We&&"text-transparent"),value:Ne,placeholder:dt,onChange:e=>{if(Ie(e),A){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void A(0);if(t>=11)return;let s=0;t>1&&(s=50),A(24*(t-1)+s)}},onKeyDown:e=>{X||Ue||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),pe||ae||mt()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),Z(!1),yield me(e))}))},_&&{onFocus:_},E&&{onBlur:E},{dir:G?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Le,className:C.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",ft?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!ft&&st.backgroundColor&&{backgroundColor:st.backgroundColor}),{borderTopRightRadius:U.cornerRadius+"px",borderBottomRightRadius:U.cornerRadius+"px"})},{children:ae?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Me.current&&(Me.current.abort(),Me.current=null),Pe.current&&(Pe.current.cancel(),Pe.current=null),ce("idle")},style:{backgroundColor:V.accent,color:V.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):We?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:I.default.stopListening,style:{backgroundColor:V.accent,color:V.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[at&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ge?V.accent+"10":void 0,color:Ge?V.accent:V.accent+"80"},disabled:pe||ae,onClick:()=>{var e;return null===(e=Re.current)||void 0===e?void 0:e.click()}},Qe,{children:[t.jsx("input",{id:"file-upload",ref:Re,type:"file",accept:[...g.allowedFileMimeTypes,...g.allowedImageMimeTypes,...g.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Z(!1),yield me(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(y.default,{className:"h-6 w-6 shrink-0"})]})),lt&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:We?V.accent:Ze?V.accent+"10":void 0,color:We?V.accentText:Ze?V.accent:V.accent+"80"},disabled:pe||ae,onClick:()=>{We?I.default.stopListening():(Te.current=Ne,Be(),I.default.startListening({continuous:!0,interimResults:!0,language:K||"en-US"}))}},et,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ke||ht?V.accent:V.accent+"10",color:Ke||ht?V.accentText:V.accent+"80"},disabled:!ht,onClick:()=>mt()},Xe,{children:t.jsx(b.default,{className:C.default("h-6 w-6 shrink-0",G&&"scale-x-[-1] transform")})}))]})}))]})),he&&t.jsx(S.default,{error:he,className:"mt-3"})]}))}))}));_.displayName="Input",exports.default=_;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react");require("../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),c=require("../../../hooks/pickaxe/useDimensionContext.js"),u=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),h=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),y=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),w=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),S=require("../../Core/ErrorAlert.js"),k=require("../../../common/error.js"),C=require("../../../common/cn.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var I=N(n);const _=s.forwardRef((({resubmitPrompt:N,onFocus:_,onBlur:E,onInputHeightChange:A,initSmitheryAuthData:q},R)=>{var T,P,D;const{origin:L,pickaxeId:H,sessionId:M,sender:F,senderType:$,deploymentId:W,deploymentType:B,pickaxe:J,styles:U,colors:V,locale:K,forceMobile:X,isNewChat:z,isRtl:G,isEmailLogin:Q,isShowFeedbackMessage:Y,setIsNewChat:Z,setIsShowIceBreaker:ee,onGenerateComplete:te}=i.usePickaxeContext(),{token:se,isLoggedOut:ne,isSent:ie}=u.useAuthContext(),{messages:re,isGenerating:oe,setMessages:ae,setStatus:le,setLimitData:ce,setError:ue}=r.useResponseContext(),{documents:de,isUploading:fe,documentError:pe,onFileUpload:me,setDocuments:he,setDocumentError:ge}=d.useDocument(),{scrollStartSession:ve,scrollEndSession:ye,scrollToBottom:be}=f.useScroll({auto:!0}),{artifacts:xe,currentPopupType:je,setArtifacts:we,setCurrentArtifact:Oe}=p.useArtifactContext(),{height:Se}=c.useDimensionContext(),ke=l.useConversation(),[Ce,Ne]=s.useState(""),[Ie,_e]=s.useState(!1),[Ee,Ae]=s.useState(!1),qe=s.useRef(null),Re=s.useRef(""),Te=s.useRef(null),Pe=s.useRef(null),De=s.useRef(null),Le=s.useRef(null),He=s.useRef(null),Me=Math.max(.4*Se,100),{transcript:Fe,listening:$e,resetTranscript:We,browserSupportsSpeechRecognition:Be}=n.useSpeechRecognition(),[Je]=h.useMediaQuery("(max-width: 480px)"),Ue=m.useHover(),{isHover:Ve}=Ue,Ke=e.__rest(Ue,["isHover"]),Xe=m.useHover(),{isHover:ze}=Xe,Ge=e.__rest(Xe,["isHover"]),Qe=m.useHover(),{isHover:Ye}=Qe,Ze=e.__rest(Qe,["isHover"]),et=a.useStyleFontSize(),tt=o.useStyleInput(),st="undefined"!=typeof window?window.location.hostname:"",nt="undefined"!=typeof window?window.location.href:"",it="undefined"!=typeof window&&window.self!==window.top,rt=st.includes("pickaxe.co")&&!nt.includes("https://studio.pickaxe.co/_embed")&&!it,ot=null===(T=null==J?void 0:J.documentuploadtype)||void 0===T?void 0:T.startsWith("enduserupload"),at=Be&&(null==J?void 0:J.enablevoicetotext),lt="chat-input"===B&&z&&!ie,ct="chat-input"===B&&Q&&ne&&ie,ut=null!==(P=null==J?void 0:J.placeholdertext)&&void 0!==P?P:G?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",dt=Ie||Ee,ft=s.useMemo((()=>{var e,t,s;return!!z&&(!!J&&(!ke.isLoading&&(!((null!==(t=null===(e=ke.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=J.icebreakers)||void 0===s?void 0:s.length)&&(!Y&&!lt)))))}),[J,z,Y,lt,ke.data,ke.isLoading]),pt=s.useMemo((()=>{if(oe||fe)return!1;const e=de.length>0&&de.every((e=>"finished"===e.status));return!(!Ce.trim()&&!e)&&de.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[oe,fe,Ce,de]);s.useImperativeHandle(R,(()=>({onSubmit:mt}))),s.useEffect((()=>{ee(ft)}),[ft]),s.useEffect((()=>{var e;if(N){const t=Array.from(re),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;mt(s,!0)}}),[N]),s.useEffect((()=>{if(!Le.current||!A)return;const e=new ResizeObserver((e=>{for(const t of e)A(t.contentRect.height)}));return e.observe(Le.current),()=>{e.disconnect()}}),[A]),s.useEffect((()=>{if(!$e)return;const e=Re.current?`${Re.current} `:"";Ne(`${e}${Fe}`)}),[Fe,$e]),s.useEffect((()=>{if(!Pe.current)return;(()=>{if(!Pe.current)return;let e=Pe.current.scrollHeight>52;Ce.includes("\n")||de.length?e=!0:Ce.trim()||(e=!1),_e(e)})()}),[Ce,de]),s.useEffect((()=>{const e=Pe.current,t=De.current;if(!e||!t||Ie||Ce.includes("\n"))return void Ae(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=Ce||ut,document.body.appendChild(i);const r=i.offsetWidth;i.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;Ae(r>l)}),[Ce,Ie,ut]);const mt=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(oe||fe)return;const r=de.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),o=r.map((e=>e.documentId)).filter(Boolean),a=r.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=o.length>0,c=null!=t?t:Ce;if(!c&&!l)return;ue(""),ge(""),ce(null),Ne(""),Z(!1),le("fetching"),ve(),be();const u=null!==(n=null===(e=null==J?void 0:J.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&o.length>0,d=[...s?Array.from(re.slice(0,re.length-1)):Array.from(re),...s?[]:[{id:re.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:u?o:[]}],{id:re.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];ae(d),be(),u&&he([]);const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:L,pickaxeId:H,sessionId:M,senderType:$,value:c},u&&{documentIds:o}),F&&{sender:F}),se&&{studioSessionToken:se}),W&&{deploymentId:W}),a.length>0&&{uploadedModelImages:a}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),rt&&{credentials:"include"})),p=yield f.json();if(!p.success){const e=new Error(p.error||"Failed to start generation");throw p.limitData&&(e.limitData=p.limitData),e}const m=p.submissionId;le("streaming"),He.current=new AbortController;const h=d.length-1,g=[];let y=[...null!=xe?xe:[]],b=0,x=!1,j="";for(;!x;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${m}?index=${b}`,{signal:null===(i=He.current)||void 0===i?void 0:i.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Te.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&b++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return ue(t),void(x=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&q){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw x=!0,q({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw x=!0,q({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)j="",g.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("text-end"===n.type)j="";else if("reasoning-start"===n.type)j="",g.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("reasoning-end"===n.type)j="";else if(n.type.startsWith("data-")){const e=n;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ae([...d.slice(0,h),Object.assign(Object.assign({},d[d.length-1]),{id:re.length+1,role:"assistant",parts:g})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);y=y.filter((e=>!(e.id===t.id&&e.version===t.version))),y.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),we([...y]),je.startsWith("inline")||Oe({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);y=y.filter((e=>!(e.id===t.id&&e.version===t.version))),y.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),we(y),je.startsWith("inline")||Oe({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);y=y.filter((e=>!(e.id===t.id&&e.version===t.version))),y.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),we(y),je.startsWith("inline")||Oe({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");y=y.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),we(y)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);we(y.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);ue(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(x=!0)}else x=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}x||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(x=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==te||te(M)}catch(e){if(e.limitData)ce(e.limitData),ue("");else{let t=k.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),ue(t)}}finally{be(),le("idle"),ye(),Te.current=null}}));return ct?null:t.jsx("div",Object.assign({className:C.default("flex w-full flex-shrink-0 flex-col items-center",!lt&&"px-4 pb-8"),dir:G?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Le,className:C.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===U.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},tt),{maxHeight:`${Me}px`,overflowY:"auto"})},{children:[$e&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(D=V.accent)&&void 0!==D?D:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:V.text+"90"}},{children:"Listening..."}))]})),!oe&&de.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:oe}),t.jsx(O.default,Object.assign({ref:Pe,className:C.default(et.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Ce.trim()&&!Ce.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",G?"text-right":"text-left",dt&&"mb-12",$e&&"text-transparent"),value:Ce,placeholder:ut,onChange:e=>{if(Ne(e),A){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void A(0);if(t>=11)return;let s=0;t>1&&(s=50),A(24*(t-1)+s)}},onKeyDown:e=>{X||Je||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),fe||oe||mt()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),Z(!1),yield me(e))}))},_&&{onFocus:_},E&&{onBlur:E},{dir:G?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:De,className:C.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",dt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!dt&&tt.backgroundColor&&{backgroundColor:tt.backgroundColor}),{borderTopRightRadius:U.cornerRadius+"px",borderBottomRightRadius:U.cornerRadius+"px"})},{children:oe?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{He.current&&(He.current.abort(),He.current=null),Te.current&&(Te.current.cancel(),Te.current=null),le("idle")},style:{backgroundColor:V.accent,color:V.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):$e?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:I.default.stopListening,style:{backgroundColor:V.accent,color:V.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[ot&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:ze?V.accent+"10":void 0,color:ze?V.accent:V.accent+"80"},disabled:fe||oe,onClick:()=>{var e;return null===(e=qe.current)||void 0===e?void 0:e.click()}},Ge,{children:[t.jsx("input",{id:"file-upload",ref:qe,type:"file",accept:[...g.allowedFileMimeTypes,...g.allowedImageMimeTypes,...g.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Z(!1),yield me(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(y.default,{className:"h-6 w-6 shrink-0"})]})),at&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:$e?V.accent:Ye?V.accent+"10":void 0,color:$e?V.accentText:Ye?V.accent:V.accent+"80"},disabled:fe||oe,onClick:()=>{$e?I.default.stopListening():(Re.current=Ce,We(),I.default.startListening({continuous:!0,interimResults:!0,language:K||"en-US"}))}},Ze,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ve||pt?V.accent:V.accent+"10",color:Ve||pt?V.accentText:V.accent+"80"},disabled:!pt,onClick:()=>mt()},Ke,{children:t.jsx(b.default,{className:C.default("h-6 w-6 shrink-0",G&&"scale-x-[-1] transform")})}))]})}))]})),pe&&t.jsx(S.default,{error:pe,className:"mt-3"})]}))}))}));_.displayName="Input",exports.default=_;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Scroll/hooks/useScroll.js"),l=require("../../Addons/Artifact/hooks/useArtifactContext.js"),d=require("../../../../common/utils.js"),c=require("@nem035/gpt-3-encoder"),u=require("eventsource-parser"),p=require("../../common/PickaxeBranding.js"),m=require("../../common/PickaxeButton.js"),g=require("../../../../common/error.js");exports.default=({questions:f,resetQuestions:h})=>{var v;const{origin:b,pickaxeId:x,sender:y,senderType:j,deploymentId:O,pickaxe:w,misc:C,translations:S,isRtl:k,setSessionId:I,setIsNewChat:_,onGenerateComplete:P}=n.usePickaxeContext(),{token:A}=i.useAuthContext(),{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Scroll/hooks/useScroll.js"),l=require("../../Addons/Artifact/hooks/useArtifactContext.js"),d=require("../../../../common/utils.js"),c=require("@nem035/gpt-3-encoder"),u=require("eventsource-parser"),p=require("../../common/PickaxeBranding.js"),m=require("../../common/PickaxeButton.js"),g=require("../../../../common/error.js");exports.default=({questions:f,resetQuestions:h})=>{var v;const{origin:b,pickaxeId:x,sender:y,senderType:j,deploymentId:O,pickaxe:w,misc:C,translations:S,isRtl:k,setSessionId:I,setIsNewChat:_,onGenerateComplete:P}=n.usePickaxeContext(),{token:A}=i.useAuthContext(),{isGenerating:N,setResponse:q,setMessages:E,setStatus:T,setLimitData:D,setError:U,setIsSwitchedToChat:L}=o.useResponseContext(),{documents:R,websiteLink:J,isUploading:B,onWebsiteUpload:K,setDocuments:W,setDocumentError:X}=r.useDocument(),{scrollStartSession:V,scrollEndSession:M,scrollToTarget:$}=a.useScroll({auto:!(null==w?void 0:w.enablechatresponses)}),{artifacts:F,currentPopupType:G,setArtifacts:Q,setCurrentArtifact:Y}=l.useArtifactContext(),[z,H]=s.useState(!1),Z=s.useRef(null),ee=s.useMemo((()=>f.some((e=>("Short Answer"===e.type||"Long Answer"===e.type||"long"===e.type||"short"===e.type||"Checkbox"===e.type||"Knowledge Upload"===e.type||e.id.includes("documentupload"))&&e.input.length>0))),[f]);return t.jsxs("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:k?"rtl":"ltr"},{children:[t.jsxs("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[t.jsx(m.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:B||N||z,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,s;try{if(N||B||z)return;U(""),X(""),D(null),q(null);const n=["Multiple Choice","Checkbox"];for(const e of f){if(c.encode(e.input).length>e.maxLength&&!n.includes(e.type))throw new Error("One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error("You must fill out all required fields.")}const i=R.filter((e=>"finished"===e.status)),o=R.map((e=>e.name)),r=null!==(t=null===(e=null==w?void 0:w.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==t&&t,a=f.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),l=d.extractUrlsFromText(J).filter((e=>!o.includes(e)));if(l.length){const e=l[l.length-1];H(!0);const t=yield K(e);t&&(i.push(t),yield new Promise((e=>setTimeout(e,5e3)))),H(!1)}else if(a&&r&&!i.length)return void X("Please paste a valid website/video link or drag a file to add to the knowledge base.");const p=i.map((e=>e.documentId||"")).filter(Boolean),m=r&&p.length>0,g={};f.forEach((e=>{g[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?i.map((e=>e.name)).join(",")||"":e.input})),T("fetching"),V(),$();const h=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({origin:b,pickaxeId:x,senderType:j,valueObj:g},m&&{documentIds:p}),y&&{sender:y}),A&&{studioSessionToken:A}),O&&{deploymentId:O}))}),v=yield h.json();if(!v.success){const e=new Error(v.error||"Failed to start generation");throw v.limitData&&(e.limitData=v.limitData),e}const C=v.submissionId,S=v.sessionId,k={sessionId:S,documentIds:m?p:[],question:{inputs:f.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};q(k),(null==w?void 0:w.enablechatresponses)&&(I(S),_(!1),L(!0),E([{id:0,role:"assistant",parts:[],documentIds:[]}])),m&&W([]),T("streaming"),Z.current=new AbortController;const M=[];let ee=[...null!=F?F:[]],te=0,se=!1,ne="";for(;!se;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${C}?index=${te}`,{signal:null===(s=Z.current)||void 0===s?void 0:s.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader(),n=new TextDecoder,i=u.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&te++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return U(t),void(se=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)ne="",M.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)ne+=n.delta,M[M.length-1].content=ne;else if("text-end"===n.type)ne="";else if("reasoning-start"===n.type)ne="",M.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)ne+=n.delta,M[M.length-1].content=ne;else if("reasoning-end"===n.type)ne="";else if(n.type.startsWith("data-")){const e=n;M.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},k),{question:Object.assign(Object.assign({},k.question),{responseParts:[...M]})});q(i),(null==w?void 0:w.enablechatresponses)&&E([{id:0,role:"assistant",parts:[...M],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);ee=ee.filter((e=>!(e.id===t.id&&e.version===t.version))),ee.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Q([...ee]),G.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);ee=ee.filter((e=>!(e.id===t.id&&e.version===t.version))),ee.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Q([...ee]),G.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);ee=ee.filter((e=>!(e.id===t.id&&e.version===t.version))),ee.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Q([...ee]),G.startsWith("inline")||Y({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");ee=ee.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Q([...ee])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Q(ee.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else se=!0}});for(;;){const{value:e,done:s}=yield t.read();if(s)break;i.feed(n.decode(e))}se||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("AbortError"===e.name)return void(se=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==P||P(S)}catch(e){let t=g.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),U(t),$()}finally{T("idle"),H(!1),M()}}))},{children:z?(null==S?void 0:S.processing)||"Processing...":B?(null==S?void 0:S.uploading)||"Uploading...":N?(null==S?void 0:S.loading)||"Loading...":null!==(v=null==w?void 0:w.submittext)&&void 0!==v?v:"Submit"})),ee&&t.jsx(m.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:B||N||z,onClick:h},{children:(null==S?void 0:S["clear-form"])||"Clear form"}))]})),!C.isWhiteLabel&&t.jsx(p.default,{containerClassName:"justify-end"})]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),s=require("./Addons/Artifact/Provider.js"),o=require("./DimensionProvider.js"),r=require("./ResponseProvider.js"),n=require("./Addons/Document/Provider.js"),a=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:f,senderType:p,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),s=require("./Addons/Artifact/Provider.js"),o=require("./DimensionProvider.js"),r=require("./ResponseProvider.js"),n=require("./Addons/Document/Provider.js"),a=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:f,senderType:p,portalId:y,deploymentId:h,deploymentType:m,deploymentDimensions:b,deploymentMisc:g,styles:v,colors:x,limits:S={},misc:j={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:w={popupType:"auto"},responsiveBy:F="viewport",locale:k="en",opacity:I=1,forceMobile:C=!1,disableHtml:O=!1,disableJs:E=!1,disableCss:D=!1,loadFont:T=!0,isRtl:q=!1,isEmbed:H=!1,isDropShadow:L=!1,isEmailLogin:M=!1,allowGuestUsage:R=!0,onGenerateComplete:_})=>{const[A,B]=i.useState(""),[G,N]=i.useState(""),[U,W]=i.useState(""),[z,J]=i.useState(""),[Y,K]=i.useState(f),[Q,V]=i.useState(p),[X,Z]=i.useState(null),[$,ee]=i.useState(!1),[te,ie]=i.useState(!0),[se,oe]=i.useState(!0),[re,ne]=i.useState(!1);return i.useEffect((()=>{ee(!1)}),[null==v?void 0:v.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&T&&!$&&(null==v?void 0:v.font)&&"Real Head Pro"!==v.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[v.font]},active:()=>{ee(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),ee(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),ee(!0)}}))}),[T,$,null==v?void 0:v.font]),i.useEffect((()=>{K(f)}),[f]),t.jsx(d.Provider,Object.assign({value:Object.assign({origin:u,contextId:A,pickaxeId:G,sessionId:U,lastSessionId:z,sender:Y,senderType:Q,portalId:y,deploymentId:h,deploymentType:m,deploymentDimensions:b,deploymentMisc:g,pickaxe:X,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},v),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},x),misc:j,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","log-out":"Log Out","clear-form":"Clear form"},P),artifact:w,responsiveBy:F,locale:k,opacity:I,forceMobile:C,loadFont:T,disableHtml:O,disableJs:E,disableCss:D,isFontLoaded:$,isNewChat:te,isShowIceBreaker:se,isShowFeedbackMessage:re,isRtl:q,isEmbed:H,isDropShadow:L,isEmailLogin:M,allowGuestUsage:R,setContextId:B,setPickaxeId:N,setSessionId:W,setLastSessionId:J,setSender:K,setSenderType:V,setPickaxe:Z,setIsFontLoaded:ee,setIsNewChat:ie,setIsShowIceBreaker:oe,setIsShowFeedbackMessage:ne},_&&{onGenerateComplete:_})},{children:t.jsx(a.default,{children:t.jsx(o.default,{children:t.jsx(r.default,Object.assign({limits:S},{children:t.jsx(n.default,{children:t.jsx(s.ArtifactProvider,Object.assign({},w,{children:c}))})}))})})}))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),i=require("react"),t=require("../../../hooks/pickaxe/usePickaxeContext.js"),a=require("./PickaxeButton.js"),r=require("./PickaxeCommon.js"),n=require("./PickaxeCurrency.js"),o=require("./PickaxeAvatar.js"),c=require("../Addons/Auth/hooks/useAuthContext.js"),l=require("../../../common/api/pickaxe.js"),d=require("../../../common/utils.js"),u=require("../../../hooks/pickaxe/useResponseContext.js");exports.default=({data:x,children:m,upgradeUrl:p})=>{var f;const{limitData:j}=u.useResponseContext(),{colors:b,sender:v,pickaxe:h}=t.usePickaxeContext(),{token:k}=c.useAuthContext(),y=i.useMemo((()=>{var e;return null!==(e=x.displayName)&&void 0!==e?e:x.name}),[x]),g=i.useMemo((()=>{var e;return null!==(e=x.displayDescription)&&void 0!==e?e:x.description}),[x]),O=i.useMemo((()=>{var e;const{price:s,priceInterval:i,currency:t}=x;if(!s)return{price:"Free",suffix:""};const a=r.intervalToSuffix(i,!0);return{price:`${(null!==(e=n.currencyOptions.find((e=>e.id===t)))&&void 0!==e?e:n.currencyOptions[0]).symbol}${s.toLocaleString()}`,suffix:a}}),[x]),w=i.useMemo((()=>{const{limit:e,limitInterval:s}=x;if(e===r.STUDIO_INFINITY_VALUE)return{limit:"Unlimited",suffix:""};const i=r.intervalToSuffix(s,!0);return{limit:e.toLocaleString(),suffix:i}}),[x]);return s.jsxs("div",Object.assign({className:"relative flex min-h-[260px] w-[220px] shrink-0 snap-center flex-col justify-between rounded-xl border p-4 shadow-sm",style:{backgroundColor:b.secondary,color:b.secondaryText}},{children:[m,s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsxs(o.Avatar,Object.assign({className:"h-8 w-8"},{children:[s.jsx(o.AvatarImage,{src:null!==(f=x.image)&&void 0!==f?f:"",alt:y}),s.jsx(o.AvatarFallback,{})]})),s.jsx("p",Object.assign({className:"mt-2 text-sm font-semibold line-clamp-1",title:y},{children:y})),Boolean(g)&&s.jsx("p",Object.assign({className:"mt-1 text-[10px] opacity-70 line-clamp-2 leading-tight"},{children:g})),s.jsxs("p",Object.assign({className:"mt-2 text-base font-semibold"},{children:[O.price,s.jsx("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:O.suffix}))]}))]})),s.jsxs("div",Object.assign({className:"mt-3 flex flex-col border-t py-2",style:{borderTopColor:b.secondaryText}},{children:[s.jsx("span",Object.assign({className:"text-[10px] font-bold opacity-50"},{children:"USES"})),s.jsxs("p",Object.assign({className:"text-base font-semibold"},{children:[w.limit,s.jsx("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:w.suffix}))]}))]}))]})),s.jsx(a.default,Object.assign({variant:"primary",className:"w-full mt-2 min-h-[32px] text-xs",onClick:()=>{v||k?e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield l.default.post("/access_group_checkout",{data:{studioUserId:v||void 0,studioId:null==h?void 0:h.studioid,accessGroupId:x.accessGroupId,successUrl:document.URL,isEmbed:d.isInIframe(),studioSessionToken:k}});if(e.data.success){const s=e.data.url;if(s)if(d.isInIframe())try{window.open(s,"_blank")}catch(e){window.open(s,"_blank")}else window.location.href=s;else window.location.reload()}else{const s=e.data.error;alert(s)}}catch(e){alert(e)}})):window.open(p||(null==j?void 0:j.limitLink))}},{children:x.ctaButtonText}))]}))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),a=require("react/jsx-runtime"),s=require("react"),r=require("../../../common/cn.js"),t=require("@radix-ui/react-avatar");function l(e){if(e&&e.__esModule)return e;var a=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(a,s,r.get?r:{enumerable:!0,get:function(){return e[s]}})}})),a.default=e,Object.freeze(a)}var c=l(s),n=l(t);const d=c.forwardRef(((s,t)=>{var{className:l}=s,c=e.__rest(s,["className"]);return a.jsx(n.Root,Object.assign({ref:t,className:r.default("relative flex h-6 w-6 shrink-0 overflow-hidden rounded-full",l)},c))}));d.displayName=n.Root.displayName;const i=c.forwardRef(((s,t)=>{var{className:l}=s,c=e.__rest(s,["className"]);return a.jsx(n.Image,Object.assign({ref:t,className:r.default("aspect-square h-full w-full",l)},c))}));i.displayName=n.Image.displayName;const u=c.forwardRef(((s,t)=>{var{className:l}=s,c=e.__rest(s,["className"]);return a.jsx(n.Fallback,Object.assign({ref:t,className:r.default("flex h-full w-full select-none items-center justify-center rounded-full bg-muted text-sm text-muted-foreground",l)},c))}));u.displayName=n.Fallback.displayName;const o=c.forwardRef(((s,t)=>{var{className:l,data:c,max:n=5,avatarClassName:o}=s,m=e.__rest(s,["className","data","max","avatarClassName"]);const f=n&&c.length>n,x=f?c.slice(0,n):c,j=f?c.length-n:0;return a.jsxs("div",Object.assign({ref:t,className:r.default("flex items-center",l)},m,{children:[x.map((({src:e,initials:s},t)=>a.jsx("div",Object.assign({className:r.default(0!==t&&"-ml-2","rounded-full border-2 border-background"),style:{zIndex:x.length-t}},{children:a.jsxs(d,Object.assign({},o&&{className:o},{children:[a.jsx(i,{src:e}),a.jsx(u,Object.assign({className:"text-xs"},{children:s}))]}))}),t))),f&&a.jsxs("div",Object.assign({className:r.default("text-sm text-muted-foreground",0!==x.length&&"ml-1"),style:{zIndex:0}},{children:["+",j]}))]}))}));o.displayName="AvatarGroup",exports.Avatar=d,exports.AvatarFallback=u,exports.AvatarGroup=o,exports.AvatarImage=i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.STUDIO_INFINITY_VALUE=-1337,exports.intervalToSuffix=(e,r=!1)=>"day"===e?r?"/daily":"/day":"week"===e?r?"/weekly":"/wk":"month"===e?r?"/monthly":"/mo":"year"===e?r?"/yearly":"/yr":"";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.currencyOptions=[{id:"usd",label:"US Dollar ($)",min:.5,symbol:"$",decimals:2},{id:"eur",label:"Euro (€)",min:.5,symbol:"€",decimals:2},{id:"gbp",label:"British Pound (£)",min:.3,symbol:"£",decimals:2},{id:"jpy",label:"Japanese Yen (¥)",min:50,symbol:"¥",decimals:0},{id:"aud",label:"Australian Dollar ($)",min:.5,symbol:"A$",decimals:2},{id:"cad",label:"Canadian Dollar ($)",min:.5,symbol:"C$",decimals:2},{id:"cny",label:"Chinese Yuan (¥)",min:3,symbol:"CN¥",decimals:2},{id:"chf",label:"Swiss Franc (Fr)",min:.5,symbol:"Fr",decimals:2},{id:"inr",label:"Indian Rupee (₹)",min:.5,symbol:"₹",decimals:2},{id:"sgd",label:"Singapore Dollar ($)",min:.5,symbol:"S$",decimals:2},{id:"hkd",label:"Hong Kong Dollar ($)",min:4,symbol:"HK$",decimals:2},{id:"krw",label:"South Korean Won (₩)",min:500,symbol:"₩",decimals:0},{id:"nzd",label:"New Zealand Dollar ($)",min:.5,symbol:"NZ$",decimals:2},{id:"zar",label:"South African Rand (R)",min:5,symbol:"R",decimals:2},{id:"brl",label:"Brazilian Real (R$)",min:.5,symbol:"R$",decimals:2},{id:"mxn",label:"Mexican Peso ($)",min:10,symbol:"MX$",decimals:2},{id:"sek",label:"Swedish Krona (kr)",min:3,symbol:"kr",decimals:2},{id:"nok",label:"Norwegian Krone (kr)",min:3,symbol:"kr",decimals:2},{id:"try",label:"Turkish Lira (₺)",min:.5,symbol:"₺",decimals:2},{id:"thb",label:"Thai Baht (฿)",min:10,symbol:"฿",decimals:2},{id:"pln",label:"Polish Złoty (zł)",min:2,symbol:"zł",decimals:2},{id:"myr",label:"Malaysian Ringgit (RM)",min:2,symbol:"RM",decimals:2},{id:"idr",label:"Indonesian Rupiah (Rp)",min:5e3,symbol:"Rp",decimals:2},{id:"czk",label:"Czech Koruna (Kč)",min:15,symbol:"Kč",decimals:2},{id:"bgn",label:"Bulgarian Lev (лв)",min:1,symbol:"лв",decimals:2},{id:"rub",label:"Russian Ruble (₽)",min:30,symbol:"₽",decimals:2}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),r=require("framer-motion"),a=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../hooks/studio/useStyleFontSize.js"),i=require("../../../common/utils.js"),n=require("../../Icons/circle-exclamation.svg.js"),c=require("../../Core/SpringTransition.js"),u=require("../../Core/HtmlRenderer.js"),d=require("./PickaxeButton.js"),x=require("../../../common/cn.js"),p=require("../../../common/api/pickaxe.js"),m=require("../Addons/Auth/hooks/useAuthContext.js"),f=require("./AccessGroupCardPreview.js");const j=({price:e,uses:t,isSelected:r,onClick:a,colors:o})=>s.jsxs("button",Object.assign({onClick:a,className:x.default("flex items-center gap-2 rounded-xl border px-4 py-3 shadow-sm transition-all duration-200 shrink-0",r?"border-2":"border opacity-80 hover:opacity-100"),style:{backgroundColor:o.secondary,color:o.secondaryText,borderColor:r?o.secondaryText:"rgba(0,0,0,0.1)"}},{children:[s.jsxs("span",Object.assign({className:"text-xl font-bold"},{children:["$",e]})),s.jsxs("span",Object.assign({className:"text-sm opacity-70"},{children:["/ ",t.toLocaleString()," uses"]}))]}));exports.default=({className:b,iconClassName:h,htmlClassName:g})=>{var y,v;const{colors:w,pickaxe:k,sender:C}=a.usePickaxeContext(),{token:N}=m.useAuthContext(),{limitData:q}=o.useResponseContext(),O=l.useStyleFontSize(),[_,A]=t.useState(0),S=window.location.href.includes("_embed"),U=i.isInIframe()&&!S?"_self":"_top";if(t.useEffect((()=>{var e;(null===(e=null==q?void 0:q.buyUses)||void 0===e?void 0:e.length)&&A(0)}),[q]),!q)return null;const I=q.limitLink,P=q.limitCTA,G=Array.isArray(q.upgradeGroups)&&q.upgradeGroups.length>0,T=Array.isArray(q.buyUses)&&q.buyUses.length>0,L=T&&Array.isArray(q.buyUses)&&q.buyUses[_];return s.jsx(r.AnimatePresence,{children:s.jsxs(c.default,Object.assign({className:x.default("flex flex-col gap-5 w-full",b)},{children:[s.jsxs("div",Object.assign({className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between rounded-lg p-3 bg-opacity-5",style:{backgroundColor:w.secondary}},{children:[s.jsxs("div",Object.assign({className:"flex gap-3 items-start"},{children:[s.jsx(n.default,{className:x.default("h-5 w-5 shrink-0 mt-0.5",h),style:{color:w.accent}}),s.jsx(u.default,{className:x.default(O.b2,"font-semibold leading-relaxed text-sm",g),style:{color:w.text},html:q.limitMessage||""})]})),P&&s.jsx("a",Object.assign({href:I,target:U,rel:"noreferrer",className:"shrink-0 w-full sm:w-auto"},{children:s.jsx(d.default,Object.assign({variant:"primary",className:"whitespace-nowrap min-h-[32px] w-full sm:w-auto text-sm"},{children:P}))}))]})),G&&s.jsxs("div",Object.assign({className:"flex flex-col gap-2"},{children:[s.jsx("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:w.text}},{children:"Available Plans"})),s.jsx("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-4 pt-1 snap-x scrollbar-thin"},{children:null===(y=q.upgradeGroups)||void 0===y?void 0:y.map(((e,t)=>s.jsx(f.default,{data:e},e.accessGroupId||t)))}))]})),T&&L&&s.jsxs("div",Object.assign({className:"flex flex-col gap-3"},{children:[s.jsx("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:w.text}},{children:"Buy Credits"})),s.jsx("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-2 pt-1 snap-x scrollbar-thin"},{children:null===(v=q.buyUses)||void 0===v?void 0:v.map(((e,t)=>s.jsx(j,{price:e.price,uses:e.uses,isSelected:t===_,onClick:()=>A(t),colors:w},t)))})),s.jsxs(d.default,Object.assign({variant:"primary",className:"w-full py-3 text-sm font-bold shadow-md",onClick:()=>{return s=L.uses,t=L.price,e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield p.default.post("/get_extra_usage_payment_link",{data:{sender:C||void 0,studioSessionToken:N,studioId:null==k?void 0:k.studioid,cost:t,extraUses:s,successUrl:document.URL}});if(e.data.success){const s=e.data.url;if(i.isInIframe())try{window.open(s,"_blank")}catch(e){window.open(s,"_blank")}else window.location.href=s}else{const s=e.data.error;alert(s)}}catch(e){alert(e)}}));var s,t}},{children:["Buy ",L.uses.toLocaleString()," Uses for $",L.price]}))]}))]}))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),a=require("react"),i=require("../../hooks/pickaxe/usePickaxeContext.js"),l=require("./Addons/Auth/hooks/useAuthContext.js"),r=require("../../hooks/pickaxe/useResponseContext.js"),c=require("./Addons/Document/hooks/useDocumentContext.js"),o=require("./Addons/Artifact/hooks/useArtifactContext.js"),n=require("uuid"),d=require("./Addons/Scroll/Provider.js"),u=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),f=require("./Addons/Auth/index.js"),p=require("../../common/cn.js"),j=require("../../common/api/pickaxe.js"),h=require("./common/AccessGroupCardPreview.js");exports.Pickaxe=({pickaxeId:g,className:b})=>{const{sessionId:v,styles:w,colors:y,responsiveBy:k,deploymentType:q,isNewChat:N,isEmailLogin:O,isEmbed:C,opacity:A,deploymentId:_,sender:P,portalId:S,setContextId:I,setPickaxeId:E,setSessionId:D,setPickaxe:L}=i.usePickaxeContext(),{isLoggedOut:R,isSent:M,token:T}=l.useAuthContext(),{setMessages:U,setResponse:F,setError:G,setLimitData:$,setIsSwitchedToChat:B}=r.useResponseContext(),{setDocumentError:H}=c.useDocumentContext(),{setCurrentArtifact:W}=o.useArtifactContext(),[z,J]=a.useState(!1),[K,Q]=a.useState("loading"),[V,X]=a.useState([]),[Y,Z]=a.useState(null),ee=t.usePickaxe(),se="chat-input"===q&&N&&!M,te="chat-input"!==q||!M;a.useEffect((()=>{E(g)}),[g]),a.useEffect((()=>{if(!_||!ee.data)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;Q("loading");try{const s=yield j.default.post("/validate_studio_deployment",{data:{deploymentId:_,sender:P||void 0,studioSessionToken:T,portalId:S,studioId:null===(e=ee.data)||void 0===e?void 0:e.studioid}});s.data.success?Q("success"):"Login required."===s.data.message?(Q("login_required"),J(!0)):"Access denied."===s.data.message?(Q("access_denied"),J(!0)):"Upgrade required."===s.data.message?(Q("upgrade_required"),X(s.data.upgradeGroups||[]),Z(s.data.upgradeUrl),J(!0)):Q("login_required")}catch(e){console.error("Failed to validate deployment:",e),Q("success")}}))}),[_,P,T,S,ee.data]),a.useEffect((()=>{if(!ee.data)return;const e=ee.data.chatflag;D(e?n.v4():""),I(n.v4()),e?U([]):F(null),G(""),H(""),$(null),W(null),B(!1),L(ee.data),J(!0)}),[ee.data]),a.useEffect((()=>{G(""),H(""),$(null),U([]),F(null),W(null)}),[v]);const ae=a.useMemo((()=>{const e=null!=A?A:1;if(!y.primary||!y.primary.startsWith("#")||e<0||e>1)return y.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${y.primary}${s}`}),[y.primary,A]);if(!ee.data)return null;return s.jsx("div",Object.assign({className:p.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===w.theme&&"dark",b),style:Object.assign({backgroundColor:se?"transparent":ae,color:y.text},w.font&&"Real Head Pro"!==w.font&&{fontFamily:w.font})},{children:ee.isLoading||!z||"loading"===K?s.jsx("div",Object.assign({className:p.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===k?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s.jsx(u.default,{className:"w-[72px] h-[72px]"}),s.jsx(u.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s.jsx(u.default,{className:p.default("w-full min-h-[48px]","viewport"===k?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===K?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:V&&V.length>0?s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[s.jsxs("div",Object.assign({className:"text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),s.jsx("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:V.map(((e,t)=>s.jsx(h.default,{data:e,upgradeUrl:Y},e.id||t)))}))]})):s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===K&&C||O&&R&&te?s.jsx(f.default,{}):"login_required"!==K||C?"access_denied"===K?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Contact tool owner to request access."}))]}))})):v?s.jsx(d.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx(d.ScrollProvider,{children:s.jsx(m.default,{})}):s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("../../../../../_virtual/_commonjsHelpers.js"),r=require("../../../../../_virtual/cose-base.js"),i=require("../../../layout-base@1.0.2/node_modules/layout-base/layout-base.js");r.__module.exports,exports.__require=function(){return t||(t=1,o=r.__module,r.__module.exports,e.commonjsGlobal,n=function(t){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}([function(e,r){e.exports=t},function(t,e,r){var i=r(0).FDLayoutConstants;function o(){}for(var n in i)o[n]=i[n];o.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,o.DEFAULT_RADIAL_SEPARATION=i.DEFAULT_EDGE_LENGTH,o.DEFAULT_COMPONENT_SEPERATION=60,o.TILE=!0,o.TILING_PADDING_VERTICAL=10,o.TILING_PADDING_HORIZONTAL=10,o.TREE_REDUCTION_ON_INCREMENTAL=!1,t.exports=o},function(t,e,r){var i=r(0).FDLayoutEdge;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraph;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraphManager;function o(t){i.call(this,t)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).FDLayoutNode,o=r(0).IMath;function n(t,e,r,o){i.call(this,t,e,r,o)}for(var a in n.prototype=Object.create(i.prototype),i)n[a]=i[a];n.prototype.move=function(){var t=this.graphManager.getLayout();this.displacementX=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementX=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementX)),Math.abs(this.displacementY)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementY=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementY)),null==this.child||0==this.child.getNodes().length?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),t.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},n.prototype.propogateDisplacementToChildren=function(t,e){for(var r,i=this.getChild().getNodes(),o=0;o<i.length;o++)null==(r=i[o]).getChild()?(r.moveBy(t,e),r.displacementX+=t,r.displacementY+=e):r.propogateDisplacementToChildren(t,e)},n.prototype.setPred1=function(t){this.pred1=t},n.prototype.getPred1=function(){return pred1},n.prototype.getPred2=function(){return pred2},n.prototype.setNext=function(t){this.next=t},n.prototype.getNext=function(){return next},n.prototype.setProcessed=function(t){this.processed=t},n.prototype.isProcessed=function(){return processed},t.exports=n},function(t,e,r){var i=r(0).FDLayout,o=r(4),n=r(3),a=r(5),s=r(2),h=r(1),d=r(0).FDLayoutConstants,g=r(0).LayoutConstants,l=r(0).Point,p=r(0).PointD,c=r(0).Layout,u=r(0).Integer,f=r(0).IGeometry,v=r(0).LGraph,T=r(0).Transform;function E(){i.call(this),this.toBeTiled={}}for(var m in E.prototype=Object.create(i.prototype),i)E[m]=i[m];E.prototype.newGraphManager=function(){var t=new o(this);return this.graphManager=t,t},E.prototype.newGraph=function(t){return new n(null,this.graphManager,t)},E.prototype.newNode=function(t){return new a(this.graphManager,t)},E.prototype.newEdge=function(t){return new s(null,null,t)},E.prototype.initParameters=function(){i.prototype.initParameters.call(this,arguments),this.isSubLayout||(h.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=h.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=h.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=d.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=d.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=d.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=d.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=d.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=d.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1,this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/d.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=d.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},E.prototype.layout=function(){return g.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},E.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental)h.TREE_REDUCTION_ON_INCREMENTAL&&(this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation(),e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)})),this.graphManager.setAllNodesToApplyGravitation(r));else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)}));this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},E.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter((function(e){return t.has(e)}));this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var r=!this.isTreeGrowing&&!this.isGrowthFinished,i=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(r,i),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},E.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},r=0;r<t.length;r++){var i=t[r].rect,o=t[r].id;e[o]={id:o,x:i.getCenterX(),y:i.getCenterY(),w:i.width,h:i.height}}return e},E.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if("during"===d.ANIMATE)this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},E.prototype.calculateNodesToApplyGravitationTo=function(){var t,e,r=[],i=this.graphManager.getGraphs(),o=i.length;for(e=0;e<o;e++)(t=i[e]).updateConnected(),t.isConnected||(r=r.concat(t.getNodes()));return r},E.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e,r=new Set;for(e=0;e<t.length;e++){var i=t[e];if(!r.has(i)){var o=i.getSource(),n=i.getTarget();if(o==n)i.getBendpoints().push(new p),i.getBendpoints().push(new p),this.createDummyNodesForBendpoints(i),r.add(i);else{var a=[];if(a=(a=a.concat(o.getEdgeListToNode(n))).concat(n.getEdgeListToNode(o)),!r.has(a[0])){var s;if(a.length>1)for(s=0;s<a.length;s++){var h=a[s];h.getBendpoints().push(new p),this.createDummyNodesForBendpoints(h)}a.forEach((function(t){r.add(t)}))}}}if(r.size==t.length)break}},E.prototype.positionNodesRadially=function(t){for(var e=new l(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,n=0,a=new p(0,0),s=0;s<t.length;s++){s%r==0&&(n=0,o=i,0!=s&&(o+=h.DEFAULT_COMPONENT_SEPERATION),i=0);var d=t[s],u=c.findCenterOfTree(d);e.x=n,e.y=o,(a=E.radialLayout(d,u,e)).y>i&&(i=Math.floor(a.y)),n=Math.floor(a.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(g.WORLD_CENTER_X-a.x/2,g.WORLD_CENTER_Y-a.y/2))},E.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),h.DEFAULT_RADIAL_SEPARATION);E.branchRadialLayout(e,null,0,359,0,i);var o=v.calculateBounds(t),n=new T;n.setDeviceOrgX(o.getMinX()),n.setDeviceOrgY(o.getMinY()),n.setWorldOrgX(r.x),n.setWorldOrgY(r.y);for(var a=0;a<t.length;a++)t[a].transform(n);var s=new p(o.getMaxX(),o.getMaxY());return n.inverseTransformPoint(s)},E.branchRadialLayout=function(t,e,r,i,o,n){var a=(i-r+1)/2;a<0&&(a+=180);var s=(a+r)%360*f.TWO_PI/360,h=o*Math.cos(s),d=o*Math.sin(s);t.setCenter(h,d);var g=[],l=(g=g.concat(t.getEdges())).length;null!=e&&l--;for(var p,c=0,u=g.length,v=t.getEdgesBetween(e);v.length>1;){var T=v[0];v.splice(0,1);var m=g.indexOf(T);m>=0&&g.splice(m,1),u--,l--}p=null!=e?(g.indexOf(v[0])+1)%u:0;for(var y=Math.abs(i-r)/l,N=p;c!=l;N=++N%u){var w=g[N].getOtherEnd(t);if(w!=e){var A=(r+c*y)%360,C=(A+y)%360;E.branchRadialLayout(w,t,A,C,o+n,n),c++}}},E.maxDiagonalInTree=function(t){for(var e=u.MIN_VALUE,r=0;r<t.length;r++){var i=t[r].getDiagonal();i>e&&(e=i)}return e},E.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},E.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var r=[],i=this.graphManager.getAllNodes(),o=0;o<i.length;o++){var n=(s=i[o]).getParent();0!==this.getNodeDegreeWithChildren(s)||null!=n.id&&this.getToBeTiled(n)||r.push(s)}for(o=0;o<r.length;o++){var s,h=(s=r[o]).getParent().id;void 0===e[h]&&(e[h]=[]),e[h]=e[h].concat(s)}Object.keys(e).forEach((function(r){if(e[r].length>1){var i="DummyCompound_"+r;t.memberGroups[i]=e[r];var o=e[r][0].getParent(),n=new a(t.graphManager);n.id=i,n.paddingLeft=o.paddingLeft||0,n.paddingRight=o.paddingRight||0,n.paddingBottom=o.paddingBottom||0,n.paddingTop=o.paddingTop||0,t.idToDummyNode[i]=n;var s=t.getGraphManager().add(t.newGraph(),n),h=o.getChild();h.add(n);for(var d=0;d<e[r].length;d++){var g=e[r][d];h.remove(g),s.add(g)}}}))},E.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var r=0;r<this.compoundOrder.length;r++)e[this.compoundOrder[r].id]=this.compoundOrder[r],t[this.compoundOrder[r].id]=[].concat(this.compoundOrder[r].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[r].getChild()),this.compoundOrder[r].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},E.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach((function(r){var i=t.idToDummyNode[r];e[r]=t.tileNodes(t.memberGroups[r],i.paddingLeft+i.paddingRight),i.rect.width=e[r].width,i.rect.height=e[r].height}))},E.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],r=e.id,i=e.paddingLeft,o=e.paddingTop;this.adjustLocations(this.tiledMemberPack[r],e.rect.x,e.rect.y,i,o)}},E.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach((function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,n=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,n)}))},E.prototype.getToBeTiled=function(t){var e=t.id;if(null!=this.toBeTiled[e])return this.toBeTiled[e];var r=t.getChild();if(null==r)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var n=i[o];if(this.getNodeDegree(n)>0)return this.toBeTiled[e]=!1,!1;if(null!=n.getChild()){if(!this.getToBeTiled(n))return this.toBeTiled[e]=!1,!1}else this.toBeTiled[n.id]=!1}return this.toBeTiled[e]=!0,!0},E.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),r=0,i=0;i<e.length;i++){var o=e[i];o.getSource().id!==o.getTarget().id&&(r+=1)}return r},E.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(null==t.getChild())return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},E.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},E.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];null!=r.getChild()&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},E.prototype.adjustLocations=function(t,e,r,i,o){r+=o;for(var n=e+=i,a=0;a<t.rows.length;a++){var s=t.rows[a];e=n;for(var h=0,d=0;d<s.length;d++){var g=s[d];g.rect.x=e,g.rect.y=r,e+=g.rect.width+t.horizontalPadding,g.rect.height>h&&(h=g.rect.height)}r+=h+t.verticalPadding}},E.prototype.tileCompoundMembers=function(t,e){var r=this;this.tiledMemberPack=[],Object.keys(t).forEach((function(i){var o=e[i];r.tiledMemberPack[i]=r.tileNodes(t[i],o.paddingLeft+o.paddingRight),o.rect.width=r.tiledMemberPack[i].width,o.rect.height=r.tiledMemberPack[i].height}))},E.prototype.tileNodes=function(t,e){var r={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:h.TILING_PADDING_VERTICAL,horizontalPadding:h.TILING_PADDING_HORIZONTAL};t.sort((function(t,e){return t.rect.width*t.rect.height>e.rect.width*e.rect.height?-1:t.rect.width*t.rect.height<e.rect.width*e.rect.height?1:0}));for(var i=0;i<t.length;i++){var o=t[i];0==r.rows.length?this.insertNodeToRow(r,o,0,e):this.canAddHorizontal(r,o.rect.width,o.rect.height)?this.insertNodeToRow(r,o,this.getShortestRowIndex(r),e):this.insertNodeToRow(r,o,r.rows.length,e),this.shiftToLastRow(r)}return r},E.prototype.insertNodeToRow=function(t,e,r,i){var o=i;r==t.rows.length&&(t.rows.push([]),t.rowWidth.push(o),t.rowHeight.push(0));var n=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(n+=t.horizontalPadding),t.rowWidth[r]=n,t.width<n&&(t.width=n);var a=e.rect.height;r>0&&(a+=t.verticalPadding);var s=0;a>t.rowHeight[r]&&(s=t.rowHeight[r],t.rowHeight[r]=a,s=t.rowHeight[r]-s),t.height+=s,t.rows[r].push(e)},E.prototype.getShortestRowIndex=function(t){for(var e=-1,r=Number.MAX_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]<r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.getLongestRowIndex=function(t){for(var e=-1,r=Number.MIN_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]>r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.canAddHorizontal=function(t,e,r){var i=this.getShortestRowIndex(t);if(i<0)return!0;var o=t.rowWidth[i];if(o+t.horizontalPadding+e<=t.width)return!0;var n,a,s=0;return t.rowHeight[i]<r&&i>0&&(s=r+t.verticalPadding-t.rowHeight[i]),n=t.width-o>=e+t.horizontalPadding?(t.height+s)/(o+e+t.horizontalPadding):(t.height+s)/t.width,s=r+t.verticalPadding,(a=t.width<e?(t.height+s)/e:(t.height+s)/t.width)<1&&(a=1/a),n<1&&(n=1/n),n<a},E.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],n=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>n&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-n,t.rowWidth[r]=t.rowWidth[r]+n,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var a=Number.MIN_VALUE,s=0;s<i.length;s++)i[s].height>a&&(a=i[s].height);e>0&&(a+=t.verticalPadding);var h=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=a,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var d=t.rowHeight[e]+t.rowHeight[r];t.height+=d-h,this.shiftToLastRow(t)}},E.prototype.tilingPreLayout=function(){h.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},E.prototype.tilingPostLayout=function(){h.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},E.prototype.reduceTrees=function(){for(var t,e=[],r=!0;r;){var i=this.graphManager.getAllNodes(),o=[];r=!1;for(var n=0;n<i.length;n++)1!=(t=i[n]).getEdges().length||t.getEdges()[0].isInterGraph||null!=t.getChild()||(o.push([t,t.getEdges()[0],t.getOwner()]),r=!0);if(1==r){for(var a=[],s=0;s<o.length;s++)1==o[s][0].getEdges().length&&(a.push(o[s]),o[s][0].getOwner().remove(o[s][0]));e.push(a),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=e},E.prototype.growTree=function(t){for(var e,r=t[t.length-1],i=0;i<r.length;i++)e=r[i],this.findPlaceforPrunedNode(e),e[2].add(e[0]),e[2].add(e[1],e[1].source,e[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},E.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0],o=(r=i==t[1].source?t[1].target:t[1].source).startX,n=r.finishX,a=r.startY,s=r.finishY,h=[0,0,0,0];if(a>0)for(var g=o;g<=n;g++)h[0]+=this.grid[g][a-1].length+this.grid[g][a].length-1;if(n<this.grid.length-1)for(g=a;g<=s;g++)h[1]+=this.grid[n+1][g].length+this.grid[n][g].length-1;if(s<this.grid[0].length-1)for(g=o;g<=n;g++)h[2]+=this.grid[g][s+1].length+this.grid[g][s].length-1;if(o>0)for(g=a;g<=s;g++)h[3]+=this.grid[o-1][g].length+this.grid[o][g].length-1;for(var l,p,c=u.MAX_VALUE,f=0;f<h.length;f++)h[f]<c?(c=h[f],l=1,p=f):h[f]==c&&l++;if(3==l&&0==c)0==h[0]&&0==h[1]&&0==h[2]?e=1:0==h[0]&&0==h[1]&&0==h[3]?e=0:0==h[0]&&0==h[2]&&0==h[3]?e=3:0==h[1]&&0==h[2]&&0==h[3]&&(e=2);else if(2==l&&0==c){var v=Math.floor(2*Math.random());e=0==h[0]&&0==h[1]?0==v?0:1:0==h[0]&&0==h[2]?0==v?0:2:0==h[0]&&0==h[3]?0==v?0:3:0==h[1]&&0==h[2]?0==v?1:2:0==h[1]&&0==h[3]?0==v?1:3:0==v?2:3}else e=4==l&&0==c?v=Math.floor(4*Math.random()):p;0==e?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-d.DEFAULT_EDGE_LENGTH-i.getHeight()/2):1==e?i.setCenter(r.getCenterX()+r.getWidth()/2+d.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):2==e?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+d.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-d.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},t.exports=E},function(t,e,r){var i={};i.layoutBase=r(0),i.CoSEConstants=r(1),i.CoSEEdge=r(2),i.CoSEGraph=r(3),i.CoSEGraphManager=r(4),i.CoSELayout=r(6),i.CoSENode=r(5),t.exports=i}])},o.exports=n(i.__require())),r.__module.exports;var o,n};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("../../../../../_virtual/_commonjsHelpers.js"),r=require("../../../../../_virtual/cose-base2.js"),i=require("../../../layout-base@1.0.2/node_modules/layout-base/layout-base.js");r.__module.exports,exports.__require=function(){return t||(t=1,o=r.__module,r.__module.exports,e.commonjsGlobal,n=function(t){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}([function(e,r){e.exports=t},function(t,e,r){var i=r(0).FDLayoutConstants;function o(){}for(var n in i)o[n]=i[n];o.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,o.DEFAULT_RADIAL_SEPARATION=i.DEFAULT_EDGE_LENGTH,o.DEFAULT_COMPONENT_SEPERATION=60,o.TILE=!0,o.TILING_PADDING_VERTICAL=10,o.TILING_PADDING_HORIZONTAL=10,o.TREE_REDUCTION_ON_INCREMENTAL=!1,t.exports=o},function(t,e,r){var i=r(0).FDLayoutEdge;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraph;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraphManager;function o(t){i.call(this,t)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).FDLayoutNode,o=r(0).IMath;function n(t,e,r,o){i.call(this,t,e,r,o)}for(var a in n.prototype=Object.create(i.prototype),i)n[a]=i[a];n.prototype.move=function(){var t=this.graphManager.getLayout();this.displacementX=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementX=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementX)),Math.abs(this.displacementY)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementY=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementY)),null==this.child||0==this.child.getNodes().length?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),t.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},n.prototype.propogateDisplacementToChildren=function(t,e){for(var r,i=this.getChild().getNodes(),o=0;o<i.length;o++)null==(r=i[o]).getChild()?(r.moveBy(t,e),r.displacementX+=t,r.displacementY+=e):r.propogateDisplacementToChildren(t,e)},n.prototype.setPred1=function(t){this.pred1=t},n.prototype.getPred1=function(){return pred1},n.prototype.getPred2=function(){return pred2},n.prototype.setNext=function(t){this.next=t},n.prototype.getNext=function(){return next},n.prototype.setProcessed=function(t){this.processed=t},n.prototype.isProcessed=function(){return processed},t.exports=n},function(t,e,r){var i=r(0).FDLayout,o=r(4),n=r(3),a=r(5),s=r(2),h=r(1),d=r(0).FDLayoutConstants,g=r(0).LayoutConstants,l=r(0).Point,p=r(0).PointD,c=r(0).Layout,u=r(0).Integer,f=r(0).IGeometry,v=r(0).LGraph,T=r(0).Transform;function E(){i.call(this),this.toBeTiled={}}for(var m in E.prototype=Object.create(i.prototype),i)E[m]=i[m];E.prototype.newGraphManager=function(){var t=new o(this);return this.graphManager=t,t},E.prototype.newGraph=function(t){return new n(null,this.graphManager,t)},E.prototype.newNode=function(t){return new a(this.graphManager,t)},E.prototype.newEdge=function(t){return new s(null,null,t)},E.prototype.initParameters=function(){i.prototype.initParameters.call(this,arguments),this.isSubLayout||(h.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=h.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=h.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=d.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=d.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=d.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=d.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=d.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=d.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1,this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/d.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=d.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},E.prototype.layout=function(){return g.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},E.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental)h.TREE_REDUCTION_ON_INCREMENTAL&&(this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation(),e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)})),this.graphManager.setAllNodesToApplyGravitation(r));else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)}));this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},E.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter((function(e){return t.has(e)}));this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var r=!this.isTreeGrowing&&!this.isGrowthFinished,i=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(r,i),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},E.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},r=0;r<t.length;r++){var i=t[r].rect,o=t[r].id;e[o]={id:o,x:i.getCenterX(),y:i.getCenterY(),w:i.width,h:i.height}}return e},E.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if("during"===d.ANIMATE)this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},E.prototype.calculateNodesToApplyGravitationTo=function(){var t,e,r=[],i=this.graphManager.getGraphs(),o=i.length;for(e=0;e<o;e++)(t=i[e]).updateConnected(),t.isConnected||(r=r.concat(t.getNodes()));return r},E.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e,r=new Set;for(e=0;e<t.length;e++){var i=t[e];if(!r.has(i)){var o=i.getSource(),n=i.getTarget();if(o==n)i.getBendpoints().push(new p),i.getBendpoints().push(new p),this.createDummyNodesForBendpoints(i),r.add(i);else{var a=[];if(a=(a=a.concat(o.getEdgeListToNode(n))).concat(n.getEdgeListToNode(o)),!r.has(a[0])){var s;if(a.length>1)for(s=0;s<a.length;s++){var h=a[s];h.getBendpoints().push(new p),this.createDummyNodesForBendpoints(h)}a.forEach((function(t){r.add(t)}))}}}if(r.size==t.length)break}},E.prototype.positionNodesRadially=function(t){for(var e=new l(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,n=0,a=new p(0,0),s=0;s<t.length;s++){s%r==0&&(n=0,o=i,0!=s&&(o+=h.DEFAULT_COMPONENT_SEPERATION),i=0);var d=t[s],u=c.findCenterOfTree(d);e.x=n,e.y=o,(a=E.radialLayout(d,u,e)).y>i&&(i=Math.floor(a.y)),n=Math.floor(a.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(g.WORLD_CENTER_X-a.x/2,g.WORLD_CENTER_Y-a.y/2))},E.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),h.DEFAULT_RADIAL_SEPARATION);E.branchRadialLayout(e,null,0,359,0,i);var o=v.calculateBounds(t),n=new T;n.setDeviceOrgX(o.getMinX()),n.setDeviceOrgY(o.getMinY()),n.setWorldOrgX(r.x),n.setWorldOrgY(r.y);for(var a=0;a<t.length;a++)t[a].transform(n);var s=new p(o.getMaxX(),o.getMaxY());return n.inverseTransformPoint(s)},E.branchRadialLayout=function(t,e,r,i,o,n){var a=(i-r+1)/2;a<0&&(a+=180);var s=(a+r)%360*f.TWO_PI/360,h=o*Math.cos(s),d=o*Math.sin(s);t.setCenter(h,d);var g=[],l=(g=g.concat(t.getEdges())).length;null!=e&&l--;for(var p,c=0,u=g.length,v=t.getEdgesBetween(e);v.length>1;){var T=v[0];v.splice(0,1);var m=g.indexOf(T);m>=0&&g.splice(m,1),u--,l--}p=null!=e?(g.indexOf(v[0])+1)%u:0;for(var y=Math.abs(i-r)/l,N=p;c!=l;N=++N%u){var w=g[N].getOtherEnd(t);if(w!=e){var A=(r+c*y)%360,C=(A+y)%360;E.branchRadialLayout(w,t,A,C,o+n,n),c++}}},E.maxDiagonalInTree=function(t){for(var e=u.MIN_VALUE,r=0;r<t.length;r++){var i=t[r].getDiagonal();i>e&&(e=i)}return e},E.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},E.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var r=[],i=this.graphManager.getAllNodes(),o=0;o<i.length;o++){var n=(s=i[o]).getParent();0!==this.getNodeDegreeWithChildren(s)||null!=n.id&&this.getToBeTiled(n)||r.push(s)}for(o=0;o<r.length;o++){var s,h=(s=r[o]).getParent().id;void 0===e[h]&&(e[h]=[]),e[h]=e[h].concat(s)}Object.keys(e).forEach((function(r){if(e[r].length>1){var i="DummyCompound_"+r;t.memberGroups[i]=e[r];var o=e[r][0].getParent(),n=new a(t.graphManager);n.id=i,n.paddingLeft=o.paddingLeft||0,n.paddingRight=o.paddingRight||0,n.paddingBottom=o.paddingBottom||0,n.paddingTop=o.paddingTop||0,t.idToDummyNode[i]=n;var s=t.getGraphManager().add(t.newGraph(),n),h=o.getChild();h.add(n);for(var d=0;d<e[r].length;d++){var g=e[r][d];h.remove(g),s.add(g)}}}))},E.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var r=0;r<this.compoundOrder.length;r++)e[this.compoundOrder[r].id]=this.compoundOrder[r],t[this.compoundOrder[r].id]=[].concat(this.compoundOrder[r].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[r].getChild()),this.compoundOrder[r].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},E.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach((function(r){var i=t.idToDummyNode[r];e[r]=t.tileNodes(t.memberGroups[r],i.paddingLeft+i.paddingRight),i.rect.width=e[r].width,i.rect.height=e[r].height}))},E.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],r=e.id,i=e.paddingLeft,o=e.paddingTop;this.adjustLocations(this.tiledMemberPack[r],e.rect.x,e.rect.y,i,o)}},E.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach((function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,n=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,n)}))},E.prototype.getToBeTiled=function(t){var e=t.id;if(null!=this.toBeTiled[e])return this.toBeTiled[e];var r=t.getChild();if(null==r)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var n=i[o];if(this.getNodeDegree(n)>0)return this.toBeTiled[e]=!1,!1;if(null!=n.getChild()){if(!this.getToBeTiled(n))return this.toBeTiled[e]=!1,!1}else this.toBeTiled[n.id]=!1}return this.toBeTiled[e]=!0,!0},E.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),r=0,i=0;i<e.length;i++){var o=e[i];o.getSource().id!==o.getTarget().id&&(r+=1)}return r},E.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(null==t.getChild())return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},E.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},E.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];null!=r.getChild()&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},E.prototype.adjustLocations=function(t,e,r,i,o){r+=o;for(var n=e+=i,a=0;a<t.rows.length;a++){var s=t.rows[a];e=n;for(var h=0,d=0;d<s.length;d++){var g=s[d];g.rect.x=e,g.rect.y=r,e+=g.rect.width+t.horizontalPadding,g.rect.height>h&&(h=g.rect.height)}r+=h+t.verticalPadding}},E.prototype.tileCompoundMembers=function(t,e){var r=this;this.tiledMemberPack=[],Object.keys(t).forEach((function(i){var o=e[i];r.tiledMemberPack[i]=r.tileNodes(t[i],o.paddingLeft+o.paddingRight),o.rect.width=r.tiledMemberPack[i].width,o.rect.height=r.tiledMemberPack[i].height}))},E.prototype.tileNodes=function(t,e){var r={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:h.TILING_PADDING_VERTICAL,horizontalPadding:h.TILING_PADDING_HORIZONTAL};t.sort((function(t,e){return t.rect.width*t.rect.height>e.rect.width*e.rect.height?-1:t.rect.width*t.rect.height<e.rect.width*e.rect.height?1:0}));for(var i=0;i<t.length;i++){var o=t[i];0==r.rows.length?this.insertNodeToRow(r,o,0,e):this.canAddHorizontal(r,o.rect.width,o.rect.height)?this.insertNodeToRow(r,o,this.getShortestRowIndex(r),e):this.insertNodeToRow(r,o,r.rows.length,e),this.shiftToLastRow(r)}return r},E.prototype.insertNodeToRow=function(t,e,r,i){var o=i;r==t.rows.length&&(t.rows.push([]),t.rowWidth.push(o),t.rowHeight.push(0));var n=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(n+=t.horizontalPadding),t.rowWidth[r]=n,t.width<n&&(t.width=n);var a=e.rect.height;r>0&&(a+=t.verticalPadding);var s=0;a>t.rowHeight[r]&&(s=t.rowHeight[r],t.rowHeight[r]=a,s=t.rowHeight[r]-s),t.height+=s,t.rows[r].push(e)},E.prototype.getShortestRowIndex=function(t){for(var e=-1,r=Number.MAX_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]<r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.getLongestRowIndex=function(t){for(var e=-1,r=Number.MIN_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]>r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.canAddHorizontal=function(t,e,r){var i=this.getShortestRowIndex(t);if(i<0)return!0;var o=t.rowWidth[i];if(o+t.horizontalPadding+e<=t.width)return!0;var n,a,s=0;return t.rowHeight[i]<r&&i>0&&(s=r+t.verticalPadding-t.rowHeight[i]),n=t.width-o>=e+t.horizontalPadding?(t.height+s)/(o+e+t.horizontalPadding):(t.height+s)/t.width,s=r+t.verticalPadding,(a=t.width<e?(t.height+s)/e:(t.height+s)/t.width)<1&&(a=1/a),n<1&&(n=1/n),n<a},E.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],n=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>n&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-n,t.rowWidth[r]=t.rowWidth[r]+n,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var a=Number.MIN_VALUE,s=0;s<i.length;s++)i[s].height>a&&(a=i[s].height);e>0&&(a+=t.verticalPadding);var h=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=a,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var d=t.rowHeight[e]+t.rowHeight[r];t.height+=d-h,this.shiftToLastRow(t)}},E.prototype.tilingPreLayout=function(){h.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},E.prototype.tilingPostLayout=function(){h.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},E.prototype.reduceTrees=function(){for(var t,e=[],r=!0;r;){var i=this.graphManager.getAllNodes(),o=[];r=!1;for(var n=0;n<i.length;n++)1!=(t=i[n]).getEdges().length||t.getEdges()[0].isInterGraph||null!=t.getChild()||(o.push([t,t.getEdges()[0],t.getOwner()]),r=!0);if(1==r){for(var a=[],s=0;s<o.length;s++)1==o[s][0].getEdges().length&&(a.push(o[s]),o[s][0].getOwner().remove(o[s][0]));e.push(a),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=e},E.prototype.growTree=function(t){for(var e,r=t[t.length-1],i=0;i<r.length;i++)e=r[i],this.findPlaceforPrunedNode(e),e[2].add(e[0]),e[2].add(e[1],e[1].source,e[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},E.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0],o=(r=i==t[1].source?t[1].target:t[1].source).startX,n=r.finishX,a=r.startY,s=r.finishY,h=[0,0,0,0];if(a>0)for(var g=o;g<=n;g++)h[0]+=this.grid[g][a-1].length+this.grid[g][a].length-1;if(n<this.grid.length-1)for(g=a;g<=s;g++)h[1]+=this.grid[n+1][g].length+this.grid[n][g].length-1;if(s<this.grid[0].length-1)for(g=o;g<=n;g++)h[2]+=this.grid[g][s+1].length+this.grid[g][s].length-1;if(o>0)for(g=a;g<=s;g++)h[3]+=this.grid[o-1][g].length+this.grid[o][g].length-1;for(var l,p,c=u.MAX_VALUE,f=0;f<h.length;f++)h[f]<c?(c=h[f],l=1,p=f):h[f]==c&&l++;if(3==l&&0==c)0==h[0]&&0==h[1]&&0==h[2]?e=1:0==h[0]&&0==h[1]&&0==h[3]?e=0:0==h[0]&&0==h[2]&&0==h[3]?e=3:0==h[1]&&0==h[2]&&0==h[3]&&(e=2);else if(2==l&&0==c){var v=Math.floor(2*Math.random());e=0==h[0]&&0==h[1]?0==v?0:1:0==h[0]&&0==h[2]?0==v?0:2:0==h[0]&&0==h[3]?0==v?0:3:0==h[1]&&0==h[2]?0==v?1:2:0==h[1]&&0==h[3]?0==v?1:3:0==v?2:3}else e=4==l&&0==c?v=Math.floor(4*Math.random()):p;0==e?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-d.DEFAULT_EDGE_LENGTH-i.getHeight()/2):1==e?i.setCenter(r.getCenterX()+r.getWidth()/2+d.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):2==e?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+d.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-d.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},t.exports=E},function(t,e,r){var i={};i.layoutBase=r(0),i.CoSEConstants=r(1),i.CoSEEdge=r(2),i.CoSEGraph=r(3),i.CoSEGraphManager=r(4),i.CoSELayout=r(6),i.CoSENode=r(5),t.exports=i}])},o.exports=n(i.__require())),r.__module.exports;var o,n};
|